From 8b312dafb7e36faff0c6b91999596d96db940f4b Mon Sep 17 00:00:00 2001 From: Nuwan Date: Tue, 27 Jan 2026 12:45:54 +0530 Subject: [PATCH] refactor(07-03): enhance chatStorage documentation - Add storage format example (JSON structure) - Document error handling strategy (graceful degradation) - Explain quota exceeded and parse error behaviors - All 8 localStorage tests still passing after refactoring Part of Phase 7 Plan 3 (WebSocket Integration & Selectors) Co-Authored-By: Claude Sonnet 4.5 --- jam-ui/src/helpers/chatStorage.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/jam-ui/src/helpers/chatStorage.js b/jam-ui/src/helpers/chatStorage.js index 286196e2d..541375a98 100644 --- a/jam-ui/src/helpers/chatStorage.js +++ b/jam-ui/src/helpers/chatStorage.js @@ -3,6 +3,20 @@ * * Stores lastReadAt timestamps for each chat channel to track unread status * across browser sessions. Data is stored as JSON object keyed by channel ID. + * + * Storage format: + * ```json + * { + * "session-abc": "2026-01-26T12:00:00Z", + * "global": "2026-01-26T13:00:00Z", + * "lesson-123": "2026-01-26T14:00:00Z" + * } + * ``` + * + * Error handling: + * - All functions catch and log errors without throwing + * - Quota exceeded errors are handled gracefully (data won't be saved but app continues) + * - JSON parse errors return empty object to allow graceful degradation */ const STORAGE_KEY = 'jk_chat_lastReadAt';