Persistent Meeting History
Overview
The Persistent Meeting History module is responsible for storing and retrieving records of past meetings, enabling users to review historical meeting cost data and to clear stored meeting history when desired. This functionality ensures that meeting cost information is preserved beyond the current session, facilitating auditing, analysis, or comparison of meetings over time.
By leveraging browser localStorage via an abstraction layer, this module addresses the problem of transient meeting data loss when the application is closed or refreshed. It allows a seamless user experience where past meetings remain accessible and manageable independently from the live meeting tracking functionality.
Core Concepts and Functionality
Data Persistence and Storage Management
At the heart of the Persistent Meeting History module is the Warehouse class, which abstracts interactions with the browser's localStorage API. This abstraction encapsulates all operations related to saving, loading, and clearing meeting data securely and efficiently.
Storage format: Meeting data is serialized as JSON strings and stored under a predefined key (default: "meetings").
Data structure: The stored data is an array of meeting objects, with each meeting represented as an array of increments reflecting attendee counts, average wages, times, and meeting purposes.
Capacity control: To prevent unbounded storage growth, the Warehouse limits the stored meetings to the 10 most recent records by removing the oldest when the limit is exceeded.
Key Warehouse methods include:
save(payload): Loads existing meeting records, appends the new meeting data, enforces the size limit, and writes back to localStorage.load(): Retrieves the entire array of past meetings from localStorage or returnsnullif none exist.remove(): Deletes the stored meetings key from localStorage, effectively clearing the history.clear(): Clears all localStorage data (less commonly used in this context).
This design isolates storage concerns from the rest of the application, promoting maintainability and potential future substitution of storage mechanisms.
Historical Meeting Data Display
The module includes a dedicated view function responsible for rendering the stored meeting data into a user-friendly table. This is implemented in the PastMeetingsTemplate view, which dynamically generates an HTML table summarizing all saved meetings.
Key features of the historical display:
Data loading: The view calls
warehouse.load()to retrieve stored meetings, parsing the JSON data into JavaScript objects.Meeting reconstruction: For each stored meeting array, a new Meeting instance is created using the saved increments to leverage Meeting's methods for summarizing data.
Summary information: Each row displays:
A sequential index number.
The date/time of the first meeting increment (start time).
The maximum number of attendees recorded during the meeting.
The total cost calculated from all increments.
The stated purpose of the meeting.
Empty state handling: If no meetings are stored, the table shows a placeholder row indicating "No past meetings."
Clear storage button state: The view enables or disables the "Clear Storage" button based on whether meeting history exists, improving UX by preventing unnecessary user actions.
This rendering approach ensures that users can easily scan, interpret, and understand their meeting history without manually parsing raw data.
Interaction with Live Meeting Tracking
While Persistent Meeting History primarily focuses on storage and display of past meetings, it closely interacts with the live meeting system through the following workflow:
When a meeting ends (stopped by the user), the current meeting data, including all increments, is saved to localStorage via the Warehouse.
The historical meetings view is refreshed to include the newly saved meeting.
Users can clear meeting history independently of live meeting operations.
The live meeting model remains decoupled from storage mechanics, delegating persistence responsibilities to the Warehouse.
This separation of concerns allows the live meeting tracking (Real-Time Meeting Cost Tracking) to focus solely on active data, while Persistent Meeting History manages archival and retrieval.
Workflow and Module Interaction
The following sequence outlines the key steps in managing persistent meeting history, illustrating the interaction between the UI, Warehouse, Meeting model, and views:
sequenceDiagram
participant User
participant UI
participant MeetingModel
participant Warehouse
participant PastMeetingsView
User->>UI: Clicks "Stop" meeting
UI->>MeetingModel: stopMeeting()
MeetingModel->>Warehouse: save(meeting data)
Warehouse-->>UI: confirmation
UI->>PastMeetingsView: updatePastMeetings()
PastMeetingsView->>Warehouse: load()
Warehouse-->>PastMeetingsView: meeting history data
PastMeetingsView->>UI: render table
User->>UI: clicks "Clear Storage"
UI->>Warehouse: remove()
Warehouse-->>UI: confirmation
UI->>PastMeetingsView: updatePastMeetings() (empty)
PastMeetingsView->>UI: render empty state
This flow ensures that the history is kept current with live meeting events and user controls.
Key File Roles and Relationships
File | Role |
|---|---|
| Implements localStorage abstraction for saving, loading, and removing meeting data. |
| Renders the past meetings table UI based on data loaded from Warehouse. |
| Coordinates user interactions, wiring meeting lifecycle events with Warehouse persistence and view updates. |
Warehouse Usage Example
In index.js, when the user stops a meeting, the meeting data is saved by calling:
meeting.stopMeeting(); // stops timer and finalizes increments
// meeting data is pushed to Warehouse internally or via explicit call
updatePastMeetings(); // triggers past meetings view refresh
The Warehouse encapsulates saving logic as:
save(payload, key=this.defaultKey) {
let pastMeetings = JSON.parse(this.load()) || [];
pastMeetings.push(payload);
if (pastMeetings.length > 10) pastMeetings.shift();
window.localStorage.setItem(key, JSON.stringify(pastMeetings));
}
Past Meetings Rendering Example
The PastMeetingsTemplate function loads saved meetings and renders them:
let data = warehouse.load();
data = (data !== null) ? JSON.parse(data) : [];
data.map(meetingData => {
const [lastIncrement] = meetingData.slice().reverse();
const meeting = new Meeting(lastIncrement.attendeeCount, lastIncrement.averageWage, warehouse, meetingData);
// Render meeting date, max attendees, total cost, purpose in table row
});
This approach leverages the Meeting model's utility methods such as getMaxAttendees() and getTotalCost() for accurate display.
Subtopics
LocalStorage Data Management: Details the internal workings and methods of the Warehouse class, focusing on reliable data persistence.
Historical Meeting Display: Explores the rendering logic and UI management of past meeting data tables and user controls for clearing history.
This detailed explanation presents the Persistent Meeting History module as a vital component for long-term meeting data management, linking live meeting tracking with durable, accessible historical records through structured storage and intuitive display.