You've already forked matrix-js-sdk
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:
@@ -2723,6 +2723,19 @@ describe("Room", function() {
|
||||
expect(room.getThreadUnreadNotificationCount("123", NotificationCountType.Total)).toBe(666);
|
||||
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", () => {
|
||||
|
@@ -173,7 +173,7 @@ export type RoomEventHandlerMap = {
|
||||
room: Room,
|
||||
) => void;
|
||||
[RoomEvent.UnreadNotifications]: (
|
||||
unreadNotifications: NotificationCount,
|
||||
unreadNotifications?: NotificationCount,
|
||||
threadId?: string,
|
||||
) => void;
|
||||
[RoomEvent.TimelineRefresh]: (room: Room, eventTimelineSet: EventTimelineSet) => void;
|
||||
@@ -1277,6 +1277,7 @@ export class Room extends ReadReceipt<RoomEmittedEvents, RoomEventHandlerMap> {
|
||||
} else {
|
||||
this.threadNotifications.clear();
|
||||
}
|
||||
this.emit(RoomEvent.UnreadNotifications);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user