Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Fix delayed badge update for mentions in encrypted rooms (#7813)
Browse files Browse the repository at this point in the history
* Fix delayed badge update for mentions in encrypted rooms

Fixes element-hq/element-web#20859

More detail on the issue

* Remove unused import

* Fix listener removal
  • Loading branch information
dbkr authored Feb 15, 2022
1 parent 8d4e830 commit a958cd2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/stores/notifications/RoomNotificationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy
this.room.on("Room.redaction", this.handleRoomEventUpdate);
this.room.on("Room.myMembership", this.handleMembershipUpdate);
this.room.on("Room.localEchoUpdated", this.handleLocalEchoUpdated);
MatrixClientPeg.get().on("Event.decrypted", this.handleRoomEventUpdate);
MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted);
MatrixClientPeg.get().on("accountData", this.handleAccountDataUpdate);
this.updateNotificationState();
}
Expand All @@ -52,7 +52,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy
this.room.removeListener("Room.myMembership", this.handleMembershipUpdate);
this.room.removeListener("Room.localEchoUpdated", this.handleLocalEchoUpdated);
if (MatrixClientPeg.get()) {
MatrixClientPeg.get().removeListener("Event.decrypted", this.handleRoomEventUpdate);
MatrixClientPeg.get().removeListener("Event.decrypted", this.onEventDecrypted);
MatrixClientPeg.get().removeListener("accountData", this.handleAccountDataUpdate);
}
}
Expand All @@ -71,8 +71,15 @@ export class RoomNotificationState extends NotificationState implements IDestroy
this.updateNotificationState();
};

private onEventDecrypted = (event: MatrixEvent) => {
if (event.getRoomId() !== this.room.roomId) return; // ignore - not for us or notifications timeline

this.updateNotificationState();
};

private handleRoomEventUpdate = (event: MatrixEvent, room: Room | null) => {
if (room?.roomId !== this.room.roomId) return; // ignore - not for us or notifications timeline

this.updateNotificationState();
};

Expand Down

0 comments on commit a958cd2

Please sign in to comment.