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

Commit

Permalink
Fix default thread notification of the new RoomHeader
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Jan 31, 2024
1 parent 7c84953 commit ec35d7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
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

0 comments on commit ec35d7c

Please sign in to comment.