fix(ws): restore "Seen" caption and live sidebar unread badges #29
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/read-receipts-and-realtime-notifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Two gaps from the axum rewrite. First, the "Seen HH:MM" caption that the original Dioxus build rendered under the sender's most recent peer-read message in a DM was never ported. The DmRead WS event was broadcast but the handler dropped it for everyone except the reader (clearing only the reader's own sidebar badge). Add a per-message "seen-{id}" slot for own-authored messages, populate it on initial render via a new find_dm_seen_state DB helper, and on each DmRead event from the peer emit two OOB swaps (clear the previous slot, set the new one) using a per-connection HashMap that tracks which slot is currently filled. Gate the indicator symmetrically on both users having read_receipts_enabled.
Second, sidebar unread badges did not update live. post_message broadcast NewMessage via broadcast_to_room, which only reaches connections currently subscribed to that room - members in other chats or on /home received nothing until they navigated. Replace that call with a broadcast_room_message helper that fans out to every relevant user (room members for private/DM rooms, all connected users for public rooms) via broadcast_to_user. The WebSocket handler now branches NewMessage on per-connection subscription state: subscribed connections render the message into #messages as before; non-subscribed recipients render an unread-badge OOB swap with a freshly-counted total. Replaces the empty-only ReadReceiptFragment with UnreadBadgeFragment that handles both clear and bump.
Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com
Two gaps from the axum rewrite. First, the "Seen HH:MM" caption that the original Dioxus build rendered under the sender's most recent peer-read message in a DM was never ported. The DmRead WS event was broadcast but the handler dropped it for everyone except the reader (clearing only the reader's own sidebar badge). Add a per-message "seen-{id}" slot for own-authored messages, populate it on initial render via a new find_dm_seen_state DB helper, and on each DmRead event from the peer emit two OOB swaps (clear the previous slot, set the new one) using a per-connection HashMap that tracks which slot is currently filled. Gate the indicator symmetrically on both users having read_receipts_enabled. Second, sidebar unread badges did not update live. post_message broadcast NewMessage via broadcast_to_room, which only reaches connections currently subscribed to that room - members in other chats or on /home received nothing until they navigated. Replace that call with a broadcast_room_message helper that fans out to every relevant user (room members for private/DM rooms, all connected users for public rooms) via broadcast_to_user. The WebSocket handler now branches NewMessage on per-connection subscription state: subscribed connections render the message into #messages as before; non-subscribed recipients render an unread-badge OOB swap with a freshly-counted total. Replaces the empty-only ReadReceiptFragment with UnreadBadgeFragment that handles both clear and bump. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>