Fix default thread notification of the new RoomHeader (#12194)
This commit is contained in:
parent
a5f9df5855
commit
a3a387a1dd
2 changed files with 12 additions and 2 deletions
|
@ -44,9 +44,12 @@ export const useRoomThreadNotifications = (room: Room): NotificationLevel => {
|
||||||
// If the current thread has unread messages, we're done.
|
// If the current thread has unread messages, we're done.
|
||||||
if (doesRoomOrThreadHaveUnreadMessages(thread)) {
|
if (doesRoomOrThreadHaveUnreadMessages(thread)) {
|
||||||
setNotificationLevel(NotificationLevel.Activity);
|
setNotificationLevel(NotificationLevel.Activity);
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// default case
|
||||||
|
setNotificationLevel(NotificationLevel.None);
|
||||||
}, [room]);
|
}, [room]);
|
||||||
|
|
||||||
useEventEmitter(room, RoomEvent.UnreadNotifications, updateNotification);
|
useEventEmitter(room, RoomEvent.UnreadNotifications, updateNotification);
|
||||||
|
|
|
@ -44,6 +44,13 @@ describe("useRoomThreadNotifications", () => {
|
||||||
expect(result.current).toBe(NotificationLevel.None);
|
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 () => {
|
it("returns red if a thread in the room has a highlight notification", async () => {
|
||||||
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 1);
|
room.setThreadUnreadNotificationCount("flooble", NotificationCountType.Highlight, 1);
|
||||||
const { result } = render(room);
|
const { result } = render(room);
|
||||||
|
@ -58,7 +65,7 @@ describe("useRoomThreadNotifications", () => {
|
||||||
expect(result.current).toBe(NotificationLevel.Notification);
|
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({
|
await populateThread({
|
||||||
room,
|
room,
|
||||||
client: cli,
|
client: cli,
|
||||||
|
|
Loading…
Reference in a new issue