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.
pull/21833/head
Travis Ralston 2020-07-30 14:33:38 -06:00
parent 5b15d12865
commit da05cac1b6
1 changed files with 6 additions and 0 deletions

View File

@ -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();