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

Fix default thread notification of the new RoomHeader #12194

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/hooks/room/useRoomThreadNotifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ export const useRoomThreadNotifications = (room: Room): NotificationLevel => {
// If the current thread has unread messages, we're done.
if (doesRoomOrThreadHaveUnreadMessages(thread)) {
setNotificationLevel(NotificationLevel.Activity);
break;
return;
}
}

// default case
setNotificationLevel(NotificationLevel.None);
}, [room]);

useEventEmitter(room, RoomEvent.UnreadNotifications, updateNotification);
Expand Down
9 changes: 8 additions & 1 deletion test/hooks/room/useRoomThreadNotifications-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ describe("useRoomThreadNotifications", () => {
expect(result.current).toBe(NotificationLevel.None);
});

it("returns none if the thread hasn't a notification anymore", async () => {
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 0);
const { result } = render(room);

expect(result.current).toBe(NotificationLevel.None);
});

it("returns red if a thread in the room has a highlight notification", async () => {
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 1);
const { result } = render(room);
Expand All @@ -58,7 +65,7 @@ describe("useRoomThreadNotifications", () => {
expect(result.current).toBe(NotificationLevel.Notification);
});

it("returns bold if a thread in the room unread messages", async () => {
it("returns activity if a thread in the room unread messages", async () => {
await populateThread({
room,
client: cli,
Expand Down
Loading