Skip to content

Commit

Permalink
regression: fix not removing room from unread group (#33983)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti authored Nov 18, 2024
1 parent 5b3f6b0 commit aed431c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions apps/meteor/client/sidebarv2/hooks/useRoomList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,21 @@ it('should add to unread group when has thread unread, even if alert is false',
const unreadGroup = result.current.roomList.splice(0, result.current.groupsCount[0]);
expect(unreadGroup.find((room) => room.name === fakeRoom.name)).toBeDefined();
});

it('should not add room to unread group if thread unread is an empty array', async () => {
const fakeRoom = {
...createFakeSubscription({ ...emptyUnread, tunread: [] }),
} as unknown as SubscriptionWithRoom;

const { result } = renderHook(() => useRoomList({ collapsedGroups: [] }), {
legacyRoot: true,
wrapper: getWrapperSettings({
sidebarGroupByType: true,
sidebarShowUnread: true,
fakeRoom,
}).build(),
});

const unreadGroup = result.current.roomList.splice(0, result.current.groupsCount[0]);
expect(unreadGroup.find((room) => room.name === fakeRoom.name)).toBeUndefined();
});
2 changes: 1 addition & 1 deletion apps/meteor/client/sidebarv2/hooks/useRoomList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const useRoomList = ({ collapsedGroups }: { collapsedGroups?: string[] })
return incomingCall.add(room);
}

if (sidebarShowUnread && (room.alert || room.unread || room.tunread) && !room.hideUnreadStatus) {
if (sidebarShowUnread && (room.alert || room.unread || room.tunread?.length) && !room.hideUnreadStatus) {
return unread.add(room);
}

Expand Down

0 comments on commit aed431c

Please sign in to comment.