diff --git a/src/app/hooks/useInboxNotificationCount.test.ts b/src/app/hooks/useInboxNotificationCount.test.ts index bcbc46c2a..770fdf997 100644 --- a/src/app/hooks/useInboxNotificationCount.test.ts +++ b/src/app/hooks/useInboxNotificationCount.test.ts @@ -20,4 +20,19 @@ describe('countInboxNotifications', () => { expect(countInboxNotifications(rooms, unread, new Set(['!dm']))).toBe(6); }); + + it('skips space rooms so aggregated space counts are not double-counted', () => { + const space = { + roomId: '!space', + isSpaceRoom: () => true, + getJoinedMemberCount: () => 3, + } as unknown as Room; + const rooms = [room('!room'), space]; + const unread = new Map([ + ['!room', { total: 4, highlight: 1, from: null }], + ['!space', { total: 4, highlight: 1, from: new Set(['!room']) }], + ]) as RoomToUnread; + + expect(countInboxNotifications(rooms, unread, new Set())).toBe(1); + }); }); diff --git a/src/app/hooks/useInboxNotificationCount.ts b/src/app/hooks/useInboxNotificationCount.ts index 6daf25efb..b12e52497 100644 --- a/src/app/hooks/useInboxNotificationCount.ts +++ b/src/app/hooks/useInboxNotificationCount.ts @@ -13,6 +13,7 @@ export const countInboxNotifications = ( mDirects: Set ): number => rooms.reduce((count, room) => { + if (room.isSpaceRoom()) return count; const unread = roomToUnread.get(room.roomId); if (!unread) return count; return count + (isDMRoom(room, mDirects) ? unread.total : unread.highlight);