1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-08-09 10:22:46 +03:00

Emit UnreadNotification event on notifications reset (#2804)

This commit is contained in:
Germain
2022-10-26 14:23:54 +01:00
committed by GitHub
parent 9f6b42d3ae
commit dddc0aeccb
2 changed files with 15 additions and 1 deletions

View File

@@ -2723,6 +2723,19 @@ describe("Room", function() {
expect(room.getThreadUnreadNotificationCount("123", NotificationCountType.Total)).toBe(666); expect(room.getThreadUnreadNotificationCount("123", NotificationCountType.Total)).toBe(666);
expect(room.getThreadUnreadNotificationCount("456", NotificationCountType.Highlight)).toBe(0); expect(room.getThreadUnreadNotificationCount("456", NotificationCountType.Highlight)).toBe(0);
}); });
it("emits event on notifications reset", () => {
const cb = jest.fn();
room.on(RoomEvent.UnreadNotifications, cb);
room.setThreadUnreadNotificationCount("123", NotificationCountType.Total, 666);
room.setThreadUnreadNotificationCount("456", NotificationCountType.Highlight, 123);
room.resetThreadUnreadNotificationCount();
expect(cb).toHaveBeenLastCalledWith();
});
}); });
describe("hasThreadUnreadNotification", () => { describe("hasThreadUnreadNotification", () => {

View File

@@ -173,7 +173,7 @@ export type RoomEventHandlerMap = {
room: Room, room: Room,
) => void; ) => void;
[RoomEvent.UnreadNotifications]: ( [RoomEvent.UnreadNotifications]: (
unreadNotifications: NotificationCount, unreadNotifications?: NotificationCount,
threadId?: string, threadId?: string,
) => void; ) => void;
[RoomEvent.TimelineRefresh]: (room: Room, eventTimelineSet: EventTimelineSet) => void; [RoomEvent.TimelineRefresh]: (room: Room, eventTimelineSet: EventTimelineSet) => void;
@@ -1277,6 +1277,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
} else { } else {
this.threadNotifications.clear(); this.threadNotifications.clear();
} }
this.emit(RoomEvent.UnreadNotifications);
} }
/** /**