wacrm/src/components/inbox
Arnas Donauskas c2ef80c7df
fix(inbox): reliable unread reset + sidebar green-dot indicator
Two issues:

1. Unread count didn't always clear when opening / viewing a
   conversation. The reset effect keyed off conversationId only, so
   a new inbound message arriving while the thread was already open
   would get the server to bump unread_count to 1, but the reset
   effect wouldn't re-fire. Split the fetch and unread-reset effects:
   fetch stays keyed on conversationId (no unnecessary refetches on
   every new message), and a second effect keyed on [conversationId,
   hasUnread] flips unread back to 0 whenever it surfaces on the
   active conversation. The hasUnread gate still prevents the
   reset→update→realtime→re-run loop.

2. No indicator elsewhere in the app when new messages arrive. Added
   useTotalUnread() hook — one-time query + realtime subscription on
   the conversations table — and a pulsing green dot on the sidebar
   Inbox entry when totalUnread > 0. Dot is hidden while on /inbox
   itself (redundant with the per-conversation badges there).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-17 21:17:28 +03:00
..
contact-sidebar.tsx perf: use getSession() instead of getUser() in client components 2026-04-16 20:05:00 +03:00
conversation-list.tsx fix: make Supabase browser client a singleton 2026-04-16 19:39:24 +03:00
message-bubble.tsx fix: media messages (image/video/audio/document/sticker) now render 2026-04-16 21:43:07 +03:00
message-composer.tsx Initial scaffold: WhatsApp CRM with Next.js + Supabase 2026-04-16 18:17:31 +03:00
message-thread.tsx fix(inbox): reliable unread reset + sidebar green-dot indicator 2026-04-17 21:17:28 +03:00