Skip to content

fix(direct): prevent double-badge on /direct/ icon for rooms in sidebar#289

Merged
Just-Insane merged 2 commits intodevfrom
fix/direct-tab-double-badge
Mar 15, 2026
Merged

fix(direct): prevent double-badge on /direct/ icon for rooms in sidebar#289
Just-Insane merged 2 commits intodevfrom
fix/direct-tab-double-badge

Conversation

@Just-Insane
Copy link
Contributor

Fixes #235

Problem

Users were seeing duplicate unread badges for the same DM room — one on the individual avatar entry in the sidebar (via DirectDMsList) and a second one on the overall /direct/ icon (via DirectTab). Both were independently summing unread counts across all DMs, so rooms shown in the sidebar were counted twice.

Solution

Extract a shared useSidebarDirectRoomIds hook that encapsulates the logic for which DM room IDs are currently rendered as individual sidebar avatars (up to 3 most-recently-active unread DMs, gated on sync-ready state).

  • DirectDMsList uses the hook directly, replacing its inline filtering/sorting/sync logic.
  • DirectTab uses the hook to build an exclusion set (sidebarRoomIds), so its badge only counts DMs that overflow beyond the sidebar list (i.e., room a discord like rich presence #4+).

Files changed

  • src/app/pages/client/sidebar/useSidebarDirectRoomIds.ts — new shared hook
  • src/app/pages/client/sidebar/DirectDMsList.tsx — use shared hook, remove duplicated logic
  • src/app/pages/client/sidebar/DirectTab.tsx — exclude sidebar rooms from badge count

The /direct/ icon badge was counting unread for all DMs, including
those already displayed as individual avatar entries in the sidebar
via DirectDMsList. This caused users to see duplicate badges — one
on the avatar entry and one on the /direct/ icon — for the same room.

Extract useSidebarDirectRoomIds hook (shared by DirectDMsList and
DirectTab) that returns the room IDs currently shown as sidebar
avatars. DirectTab now computes its badge only for DMs that overflow
beyond the MAX_SIDEBAR_DMS (3) limit shown in the sidebar.

Closes #235
@Just-Insane Just-Insane requested a review from a team March 15, 2026 18:55
@Just-Insane Just-Insane enabled auto-merge March 15, 2026 18:55
@Just-Insane Just-Insane added this pull request to the merge queue Mar 15, 2026
@github-actions
Copy link
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

Status Preview URL Commit Alias Updated (UTC)
✅ Deployment successful! https://pr-289-sable.raspy-dream-bb1d.workers.dev f8bb692 pr-289 Sun, 15 Mar 2026 18:56:47 GMT

Merged via the queue into dev with commit c3cc021 Mar 15, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove duplicate unread badges

1 participant