mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-24 11:01:17 -08:00
Fix inbox badge counting rooms twice via space aggregates
This commit is contained in:
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);
|
||||
|
||||
Reference in new issue
Block a user