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 <noreply@anthropic.com>
This commit is contained in:
Nuwan 2026-01-27 12:45:54 +05:30
parent 3cdeae691f
commit 8b312dafb7
1 changed files with 14 additions and 0 deletions

View File

@ -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';