Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a3a387a

Browse files
authored
Fix default thread notification of the new RoomHeader (#12194)
1 parent a5f9df5 commit a3a387a

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/hooks/room/useRoomThreadNotifications.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ export const useRoomThreadNotifications = (room: Room): NotificationLevel => {
4444
// If the current thread has unread messages, we're done.
4545
if (doesRoomOrThreadHaveUnreadMessages(thread)) {
4646
setNotificationLevel(NotificationLevel.Activity);
47-
break;
47+
return;
4848
}
4949
}
50+
51+
// default case
52+
setNotificationLevel(NotificationLevel.None);
5053
}, [room]);
5154

5255
useEventEmitter(room, RoomEvent.UnreadNotifications, updateNotification);

test/hooks/room/useRoomThreadNotifications-test.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ describe("useRoomThreadNotifications", () => {
4444
expect(result.current).toBe(NotificationLevel.None);
4545
});
4646

47+
it("returns none if the thread hasn't a notification anymore", async () => {
48+
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 0);
49+
const { result } = render(room);
50+
51+
expect(result.current).toBe(NotificationLevel.None);
52+
});
53+
4754
it("returns red if a thread in the room has a highlight notification", async () => {
4855
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 1);
4956
const { result } = render(room);
@@ -58,7 +65,7 @@ describe("useRoomThreadNotifications", () => {
5865
expect(result.current).toBe(NotificationLevel.Notification);
5966
});
6067

61-
it("returns bold if a thread in the room unread messages", async () => {
68+
it("returns activity if a thread in the room unread messages", async () => {
6269
await populateThread({
6370
room,
6471
client: cli,

0 commit comments

Comments
 (0)