Pass a client into RoomNotifs.getRoomNotifsState (#9631)
Pass an explicit client into `RoomNotifs.getRoomNotifsState`, rather than relying on `MatrixClientPeg`. This resolves a race condition where we have a component which thinks it is using a particular component, but `MatrixClientPeg` has been updated.
This commit is contained in:
@@ -50,7 +50,7 @@ export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedR
|
||||
private onAccountData = (event: MatrixEvent) => {
|
||||
if (event.getType() === EventType.PushRules) {
|
||||
const currentVolume = this.properties.get(CachedRoomKey.NotificationVolume);
|
||||
const newVolume = getRoomNotifsState(this.context.room.roomId);
|
||||
const newVolume = getRoomNotifsState(this.matrixClient, this.context.room.roomId);
|
||||
if (currentVolume !== newVolume) {
|
||||
this.updateNotificationVolume();
|
||||
}
|
||||
@@ -58,7 +58,10 @@ export class RoomEchoChamber extends GenericEchoChamber<RoomEchoContext, CachedR
|
||||
};
|
||||
|
||||
private updateNotificationVolume() {
|
||||
this.properties.set(CachedRoomKey.NotificationVolume, getRoomNotifsState(this.context.room.roomId));
|
||||
this.properties.set(
|
||||
CachedRoomKey.NotificationVolume,
|
||||
getRoomNotifsState(this.matrixClient, this.context.room.roomId),
|
||||
);
|
||||
this.markEchoReceived(CachedRoomKey.NotificationVolume);
|
||||
this.emit(PROPERTY_UPDATED, CachedRoomKey.NotificationVolume);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,9 @@ export class RoomNotificationState extends NotificationState implements IDestroy
|
||||
this._color = NotificationColor.Unsent;
|
||||
this._symbol = "!";
|
||||
this._count = 1; // not used, technically
|
||||
} else if (RoomNotifs.getRoomNotifsState(this.room.roomId) === RoomNotifs.RoomNotifState.Mute) {
|
||||
} else if (RoomNotifs.getRoomNotifsState(
|
||||
this.room.client, this.room.roomId,
|
||||
) === RoomNotifs.RoomNotifState.Mute) {
|
||||
// When muted we suppress all notification states, even if we have context on them.
|
||||
this._color = NotificationColor.None;
|
||||
this._symbol = null;
|
||||
|
||||
Reference in New Issue
Block a user