fix: Unread notificaitons on startup

This commit is contained in:
2026-06-04 18:18:22 +02:00
parent 161f57f52e
commit 6d021a296b
6 changed files with 227 additions and 6 deletions

View File

@@ -143,6 +143,8 @@ Unread state is modeled as a combination of persisted read markers plus in-memor
Important design constraint: unread counters are intentionally not persisted. The persisted state stores only the user-controlled settings and the read markers needed to derive unread counts again.
Read markers are written with the same server-adjusted clock that chat messages use, so a visible channel does not become unread again after reload when the signaling server clock is ahead of the local desktop clock.
### Why baselines exist
The domain must avoid marking an entire historical backlog as unread the first time a room appears.
@@ -176,6 +178,7 @@ Unread is cleared by channel, not globally.
- `markCurrentChannelReadIfActive()` only runs when the window is focused and the document is visible.
- If a live message arrives in the currently visible text channel, the domain immediately marks that channel read instead of incrementing unread.
- When a startup message load or sync batch recomputes unread counts for the viewed server, the currently visible text channel is re-cleared and its read marker advances to the newest visible message in that batch.
- Window focus and document visibility changes both clear taskbar attention and mark the active channel read.
- `pruneUnreadState()` removes deleted or non-text channels from the unread maps and re-derives room totals from channel totals.