Fix default thread notification of the new RoomHeader (#12194)

This commit is contained in:
Florian Duros 2024-01-31 17:24:56 +01:00 committed by GitHub
parent a5f9df5855
commit a3a387a1dd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -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);

View file

@ -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);
@ -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,