You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-25 05:23:13 +03:00
Clear notifications when we can infer read status from receipts (#3139)
This commit is contained in:
@@ -1307,6 +1307,8 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
this.on(ClientEvent.Sync, this.startCallEventHandler);
|
||||
}
|
||||
|
||||
this.on(ClientEvent.Sync, this.fixupRoomNotifications);
|
||||
|
||||
this.timelineSupport = Boolean(opts.timelineSupport);
|
||||
|
||||
this.cryptoStore = opts.cryptoStore;
|
||||
@@ -6817,6 +6819,31 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Once the client has been initialised, we want to clear notifications we
|
||||
* know for a fact should be here.
|
||||
* This issue should also be addressed on synapse's side and is tracked as part
|
||||
* of https://github.com/matrix-org/synapse/issues/14837
|
||||
*
|
||||
* We consider a room or a thread as fully read if the current user has sent
|
||||
* the last event in the live timeline of that context and if the read receipt
|
||||
* we have on record matches.
|
||||
*/
|
||||
private fixupRoomNotifications = (): void => {
|
||||
if (this.isInitialSyncComplete()) {
|
||||
const unreadRooms = (this.getRooms() ?? []).filter((room) => {
|
||||
return room.getUnreadNotificationCount(NotificationCountType.Total) > 0;
|
||||
});
|
||||
|
||||
for (const room of unreadRooms) {
|
||||
const currentUserId = this.getSafeUserId();
|
||||
room.fixupNotifications(currentUserId);
|
||||
}
|
||||
|
||||
this.off(ClientEvent.Sync, this.fixupRoomNotifications);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @returns Promise which resolves: ITurnServerResponse object
|
||||
* @returns Rejects: with an error response.
|
||||
|
||||
Reference in New Issue
Block a user