Apply labs flag to legacy room header too

pull/28788/head^2
Germain 2023-09-01 07:56:29 +01:00
parent 6b57ab53df
commit de88a7c8df
2 changed files with 25 additions and 15 deletions

View File

@ -27,6 +27,7 @@ import { IRightPanelCardState } from "../../../stores/right-panel/RightPanelStor
import { UPDATE_EVENT } from "../../../stores/AsyncStore"; import { UPDATE_EVENT } from "../../../stores/AsyncStore";
import { NotificationColor } from "../../../stores/notifications/NotificationColor"; import { NotificationColor } from "../../../stores/notifications/NotificationColor";
import { ActionPayload } from "../../../dispatcher/payloads"; import { ActionPayload } from "../../../dispatcher/payloads";
import SettingsStore from "../../../settings/SettingsStore";
export enum HeaderKind { export enum HeaderKind {
Room = "room", Room = "room",
@ -37,6 +38,7 @@ interface IState {
phase: RightPanelPhases | null; phase: RightPanelPhases | null;
threadNotificationColor: NotificationColor; threadNotificationColor: NotificationColor;
globalNotificationColor: NotificationColor; globalNotificationColor: NotificationColor;
notificationsEnabled?: boolean;
} }
interface IProps {} interface IProps {}
@ -44,6 +46,7 @@ interface IProps {}
export default abstract class HeaderButtons<P = {}> extends React.Component<IProps & P, IState> { export default abstract class HeaderButtons<P = {}> extends React.Component<IProps & P, IState> {
private unmounted = false; private unmounted = false;
private dispatcherRef?: string = undefined; private dispatcherRef?: string = undefined;
private readonly watcherRef: string;
public constructor(props: IProps & P, kind: HeaderKind) { public constructor(props: IProps & P, kind: HeaderKind) {
super(props); super(props);
@ -54,7 +57,11 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
phase: rps.currentCard.phase, phase: rps.currentCard.phase,
threadNotificationColor: NotificationColor.None, threadNotificationColor: NotificationColor.None,
globalNotificationColor: 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 { public componentDidMount(): void {
@ -66,6 +73,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
this.unmounted = true; this.unmounted = true;
RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate); RightPanelStore.instance.off(UPDATE_EVENT, this.onRightPanelStoreUpdate);
if (this.dispatcherRef) dis.unregister(this.dispatcherRef); if (this.dispatcherRef) dis.unregister(this.dispatcherRef);
if (this.watcherRef) SettingsStore.unwatchSetting(this.watcherRef);
} }
protected abstract onAction(payload: ActionPayload): void; protected abstract onAction(payload: ActionPayload): void;

View File

@ -308,21 +308,23 @@ export default class LegacyRoomHeaderButtons extends HeaderButtons<IProps> {
<UnreadIndicator color={this.state.threadNotificationColor} /> <UnreadIndicator color={this.state.threadNotificationColor} />
</HeaderButton>, </HeaderButton>,
); );
rightPanelPhaseButtons.set( if (this.state.notificationsEnabled) {
RightPanelPhases.NotificationPanel, rightPanelPhaseButtons.set(
<HeaderButton RightPanelPhases.NotificationPanel,
key="notifsButton" <HeaderButton
name="notifsButton" key="notifsButton"
title={_t("Notifications")} name="notifsButton"
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)} title={_t("Notifications")}
onClick={this.onNotificationsClicked} isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
isUnread={this.globalNotificationState.color === NotificationColor.Red} onClick={this.onNotificationsClicked}
> isUnread={this.globalNotificationState.color === NotificationColor.Red}
{this.globalNotificationState.color === NotificationColor.Red ? ( >
<UnreadIndicator color={this.globalNotificationState.color} /> {this.globalNotificationState.color === NotificationColor.Red ? (
) : null} <UnreadIndicator color={this.globalNotificationState.color} />
</HeaderButton>, ) : null}
); </HeaderButton>,
);
}
rightPanelPhaseButtons.set( rightPanelPhaseButtons.set(
RightPanelPhases.RoomSummary, RightPanelPhases.RoomSummary,
<HeaderButton <HeaderButton