fix(ws): restore "Seen" caption and live sidebar unread badges #29

Merged
nrupard merged 1 commit from fix/read-receipts-and-realtime-notifications into main 2026-05-04 19:13:44 +02:00
Owner

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>
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>
nrupard deleted branch fix/read-receipts-and-realtime-notifications 2026-05-04 19:13:44 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
psa-systems/lets-chat!29
No description provided.