From da05cac1b6d189fe4809cbe3ea100a25cb795851 Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Thu, 30 Jul 2020 14:33:38 -0600 Subject: [PATCH] Listen for our own membership changes on notification states Fixes https://github.com/vector-im/riot-web/issues/14798 (part 1) When we transition from invite to not-invite we need to ensure we clear the invite notification state. --- src/stores/notifications/RoomNotificationState.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/stores/notifications/RoomNotificationState.ts b/src/stores/notifications/RoomNotificationState.ts index dc38f8bf0f..3fadbe7d7a 100644 --- a/src/stores/notifications/RoomNotificationState.ts +++ b/src/stores/notifications/RoomNotificationState.ts @@ -31,6 +31,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy this.room.on("Room.receipt", this.handleReadReceipt); this.room.on("Room.timeline", this.handleRoomEventUpdate); this.room.on("Room.redaction", this.handleRoomEventUpdate); + this.room.on("Room.myMembership", this.handleMembershipUpdate); MatrixClientPeg.get().on("Event.decrypted", this.handleRoomEventUpdate); MatrixClientPeg.get().on("accountData", this.handleAccountDataUpdate); this.updateNotificationState(); @@ -45,6 +46,7 @@ export class RoomNotificationState extends NotificationState implements IDestroy this.room.removeListener("Room.receipt", this.handleReadReceipt); this.room.removeListener("Room.timeline", this.handleRoomEventUpdate); this.room.removeListener("Room.redaction", this.handleRoomEventUpdate); + this.room.removeListener("Room.myMembership", this.handleMembershipUpdate); if (MatrixClientPeg.get()) { MatrixClientPeg.get().removeListener("Event.decrypted", this.handleRoomEventUpdate); MatrixClientPeg.get().removeListener("accountData", this.handleAccountDataUpdate); @@ -57,6 +59,10 @@ export class RoomNotificationState extends NotificationState implements IDestroy this.updateNotificationState(); }; + private handleMembershipUpdate = () => { + this.updateNotificationState(); + }; + private handleRoomEventUpdate = (event: MatrixEvent) => { const roomId = event.getRoomId();