mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 03:36:07 +03:00
Merge pull request #4876 from matrix-org/travis/room-list/notif-dropdown
Update mute icon behaviour for new room list designs
This commit is contained in:
commit
ea787ad430
2 changed files with 18 additions and 4 deletions
|
@ -284,9 +284,10 @@ export default class RoomTile2 extends React.Component<IProps, IState> {
|
||||||
mx_RoomTile2_iconBell: state === ALL_MESSAGES_LOUD || state === ALL_MESSAGES,
|
mx_RoomTile2_iconBell: state === ALL_MESSAGES_LOUD || state === ALL_MESSAGES,
|
||||||
mx_RoomTile2_iconBellDot: state === MENTIONS_ONLY,
|
mx_RoomTile2_iconBellDot: state === MENTIONS_ONLY,
|
||||||
mx_RoomTile2_iconBellCrossed: state === MUTE,
|
mx_RoomTile2_iconBellCrossed: state === MUTE,
|
||||||
// XXX: RoomNotifs assumes ALL_MESSAGES is default, this is wrong,
|
|
||||||
// but cannot be fixed until FTUE Notifications lands.
|
// Only show the icon by default if the room is overridden to muted.
|
||||||
mx_RoomTile2_notificationsButton_show: state !== ALL_MESSAGES,
|
// TODO: [FTUE Notifications] Probably need to detect global mute state
|
||||||
|
mx_RoomTile2_notificationsButton_show: state === MUTE,
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -37,6 +37,7 @@ export class RoomNotificationState extends EventEmitter implements IDestroyable,
|
||||||
this.room.on("Room.timeline", this.handleRoomEventUpdate);
|
this.room.on("Room.timeline", this.handleRoomEventUpdate);
|
||||||
this.room.on("Room.redaction", this.handleRoomEventUpdate);
|
this.room.on("Room.redaction", this.handleRoomEventUpdate);
|
||||||
MatrixClientPeg.get().on("Event.decrypted", this.handleRoomEventUpdate);
|
MatrixClientPeg.get().on("Event.decrypted", this.handleRoomEventUpdate);
|
||||||
|
MatrixClientPeg.get().on("accountData", this.handleAccountDataUpdate);
|
||||||
this.updateNotificationState();
|
this.updateNotificationState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +63,7 @@ export class RoomNotificationState extends EventEmitter implements IDestroyable,
|
||||||
this.room.removeListener("Room.redaction", this.handleRoomEventUpdate);
|
this.room.removeListener("Room.redaction", this.handleRoomEventUpdate);
|
||||||
if (MatrixClientPeg.get()) {
|
if (MatrixClientPeg.get()) {
|
||||||
MatrixClientPeg.get().removeListener("Event.decrypted", this.handleRoomEventUpdate);
|
MatrixClientPeg.get().removeListener("Event.decrypted", this.handleRoomEventUpdate);
|
||||||
|
MatrixClientPeg.get().removeListener("accountData", this.handleAccountDataUpdate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,10 +80,21 @@ export class RoomNotificationState extends EventEmitter implements IDestroyable,
|
||||||
this.updateNotificationState();
|
this.updateNotificationState();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private handleAccountDataUpdate = (ev: MatrixEvent) => {
|
||||||
|
if (ev.getType() === "m.push_rules") {
|
||||||
|
this.updateNotificationState();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private updateNotificationState() {
|
private updateNotificationState() {
|
||||||
const before = {count: this.count, symbol: this.symbol, color: this.color};
|
const before = {count: this.count, symbol: this.symbol, color: this.color};
|
||||||
|
|
||||||
if (this.roomIsInvite) {
|
if (RoomNotifs.getRoomNotifsState(this.room.roomId) === RoomNotifs.MUTE) {
|
||||||
|
// When muted we suppress all notification states, even if we have context on them.
|
||||||
|
this._color = NotificationColor.None;
|
||||||
|
this._symbol = null;
|
||||||
|
this._count = 0;
|
||||||
|
} else if (this.roomIsInvite) {
|
||||||
this._color = NotificationColor.Red;
|
this._color = NotificationColor.Red;
|
||||||
this._symbol = "!";
|
this._symbol = "!";
|
||||||
this._count = 1; // not used, technically
|
this._count = 1; // not used, technically
|
||||||
|
|
Loading…
Reference in a new issue