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

Commit 662515b

Browse files
committed
Fix delayed badge update for mentions in encrypted rooms (#7813)
* 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
1 parent f7e6250 commit 662515b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/stores/notifications/RoomNotificationState.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy
3535
this.room.on("Room.redaction", this.handleRoomEventUpdate);
3636
this.room.on("Room.myMembership", this.handleMembershipUpdate);
3737
this.room.on("Room.localEchoUpdated", this.handleLocalEchoUpdated);
38-
MatrixClientPeg.get().on("Event.decrypted", this.handleRoomEventUpdate);
38+
MatrixClientPeg.get().on("Event.decrypted", this.onEventDecrypted);
3939
MatrixClientPeg.get().on("accountData", this.handleAccountDataUpdate);
4040
this.updateNotificationState();
4141
}
@@ -52,7 +52,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy
5252
this.room.removeListener("Room.myMembership", this.handleMembershipUpdate);
5353
this.room.removeListener("Room.localEchoUpdated", this.handleLocalEchoUpdated);
5454
if (MatrixClientPeg.get()) {
55-
MatrixClientPeg.get().removeListener("Event.decrypted", this.handleRoomEventUpdate);
55+
MatrixClientPeg.get().removeListener("Event.decrypted", this.onEventDecrypted);
5656
MatrixClientPeg.get().removeListener("accountData", this.handleAccountDataUpdate);
5757
}
5858
}
@@ -71,8 +71,15 @@ export class RoomNotificationState extends NotificationState implements IDestroy
7171
this.updateNotificationState();
7272
};
7373

74+
private onEventDecrypted = (event: MatrixEvent) => {
75+
if (event.getRoomId() !== this.room.roomId) return; // ignore - not for us or notifications timeline
76+
77+
this.updateNotificationState();
78+
};
79+
7480
private handleRoomEventUpdate = (event: MatrixEvent, room: Room | null) => {
7581
if (room?.roomId !== this.room.roomId) return; // ignore - not for us or notifications timeline
82+
7683
this.updateNotificationState();
7784
};
7885

0 commit comments

Comments
 (0)