Fix inbox badge counting rooms twice via space aggregates

This commit is contained in:
Erwan Leboucher committed 2026-08-11 15:01:22 +02:00
1 parent 39ae34bf46
commit 110d534a91
2 files changed
+16

No files matched your search

@@ -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);
});
});
@@ -13,6 +13,7 @@ export const countInboxNotifications = (
mDirects: Set<string>
): 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);