mirror of https://github.com/vector-im/riot-web
Apply labs flag to legacy room header too
parent
6b57ab53df
commit
de88a7c8df
|
@ -27,6 +27,7 @@ import { IRightPanelCardState } from "../../../stores/right-panel/RightPanelStor
|
|||
import { UPDATE_EVENT } from "../../../stores/AsyncStore";
|
||||
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
|
||||
import { ActionPayload } from "../../../dispatcher/payloads";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
|
||||
export enum HeaderKind {
|
||||
Room = "room",
|
||||
|
@ -37,6 +38,7 @@ interface IState {
|
|||
phase: RightPanelPhases | null;
|
||||
threadNotificationColor: NotificationColor;
|
||||
globalNotificationColor: NotificationColor;
|
||||
notificationsEnabled?: boolean;
|
||||
}
|
||||
|
||||
interface IProps {}
|
||||
|
@ -44,6 +46,7 @@ interface IProps {}
|
|||
export default abstract class HeaderButtons<P = {}> extends React.Component<IProps & P, IState> {
|
||||
private unmounted = false;
|
||||
private dispatcherRef?: string = undefined;
|
||||
private readonly watcherRef: string;
|
||||
|
||||
public constructor(props: IProps & P, kind: HeaderKind) {
|
||||
super(props);
|
||||
|
@ -54,7 +57,11 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
phase: rps.currentCard.phase,
|
||||
threadNotificationColor: NotificationColor.None,
|
||||
globalNotificationColor: NotificationColor.None,
|
||||
notificationsEnabled: SettingsStore.getValue("feature_notifications"),
|
||||
};
|
||||
this.watcherRef = SettingsStore.watchSetting("feature_notifications", null, (...[, , , value]) =>
|
||||
this.setState({ notificationsEnabled: value }),
|
||||
);
|
||||
}
|
||||
|
||||
public componentDidMount(): void {
|
||||
|
@ -66,6 +73,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
|||
this.unmounted = true;
|
||||
RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate);
|
||||
if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
|
||||
if (this.watcherRef) SettingsStore.unwatchSetting(this.watcherRef);
|
||||
}
|
||||
|
||||
protected abstract onAction(payload: ActionPayload): void;
|
||||
|
|
|
@ -308,21 +308,23 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons<IProps> {
|
|||
<UnreadIndicator color={this.state.threadNotificationColor} />
|
||||
</HeaderButton>,
|
||||
);
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.NotificationPanel,
|
||||
<HeaderButton
|
||||
key="notifsButton"
|
||||
name="notifsButton"
|
||||
title={_t("Notifications")}
|
||||
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
||||
onClick={this.onNotificationsClicked}
|
||||
isUnread={this.globalNotificationState.color === NotificationColor.Red}
|
||||
>
|
||||
{this.globalNotificationState.color === NotificationColor.Red ? (
|
||||
<UnreadIndicator color={this.globalNotificationState.color} />
|
||||
) : null}
|
||||
</HeaderButton>,
|
||||
);
|
||||
if (this.state.notificationsEnabled) {
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.NotificationPanel,
|
||||
<HeaderButton
|
||||
key="notifsButton"
|
||||
name="notifsButton"
|
||||
title={_t("Notifications")}
|
||||
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
||||
onClick={this.onNotificationsClicked}
|
||||
isUnread={this.globalNotificationState.color === NotificationColor.Red}
|
||||
>
|
||||
{this.globalNotificationState.color === NotificationColor.Red ? (
|
||||
<UnreadIndicator color={this.globalNotificationState.color} />
|
||||
) : null}
|
||||
</HeaderButton>,
|
||||
);
|
||||
}
|
||||
rightPanelPhaseButtons.set(
|
||||
RightPanelPhases.RoomSummary,
|
||||
<HeaderButton
|
||||
|
|
Loading…
Reference in New Issue