From a0d0c861214d15926d1e9e01e500646d385e1bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlia=20Jaeger=20Foresti?= <60678893+juliajforesti@users.noreply.github.com> Date: Mon, 18 Nov 2024 14:19:35 -0300 Subject: [PATCH] fix: Thread unread not in unread group (#33963) --- .changeset/sweet-needles-melt.md | 5 +++++ .../sidebarv2/hooks/useRoomList.spec.tsx | 18 ++++++++++++++++++ .../client/sidebarv2/hooks/useRoomList.ts | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .changeset/sweet-needles-melt.md diff --git a/.changeset/sweet-needles-melt.md b/.changeset/sweet-needles-melt.md new file mode 100644 index 000000000000..51cd6e03d831 --- /dev/null +++ b/.changeset/sweet-needles-melt.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': patch +--- + +Fixes edge case of thread unread not being added to unread group diff --git a/apps/meteor/client/sidebarv2/hooks/useRoomList.spec.tsx b/apps/meteor/client/sidebarv2/hooks/useRoomList.spec.tsx index d1b5d8d3c66c..4e051584c898 100644 --- a/apps/meteor/client/sidebarv2/hooks/useRoomList.spec.tsx +++ b/apps/meteor/client/sidebarv2/hooks/useRoomList.spec.tsx @@ -275,3 +275,21 @@ it('should accumulate unread data into `groupedUnreadInfo` when group is collaps expect(tunread).toEqual(fakeRooms.reduce((acc, cv) => [...acc, ...(cv.tunread || [])], [] as string[])); expect(tunreadUser).toEqual(fakeRooms.reduce((acc, cv) => [...acc, ...(cv.tunreadUser || [])], [] as string[])); }); + +it('should add to unread group when has thread unread, even if alert is false', async () => { + const fakeRoom = { + ...createFakeSubscription({ ...emptyUnread, tunread: ['1'], alert: false }), + } 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)).toBeDefined(); +}); diff --git a/apps/meteor/client/sidebarv2/hooks/useRoomList.ts b/apps/meteor/client/sidebarv2/hooks/useRoomList.ts index 6e6bfae345a1..ae58e859a8b0 100644 --- a/apps/meteor/client/sidebarv2/hooks/useRoomList.ts +++ b/apps/meteor/client/sidebarv2/hooks/useRoomList.ts @@ -78,7 +78,7 @@ export const useRoomList = ({ collapsedGroups }: { collapsedGroups?: string[] }) return incomingCall.add(room); } - if (sidebarShowUnread && (room.alert || room.unread) && !room.hideUnreadStatus) { + if (sidebarShowUnread && (room.alert || room.unread || room.tunread) && !room.hideUnreadStatus) { return unread.add(room); }