add NotifPanel dot back. (#9242)
partially fixes https://github.com/vector-im/element-web/issues/17641 provides a dot, but not a badge. fixes chronic bug 87.
This commit is contained in:
parent
52fc8ff255
commit
eb97b9674c
2 changed files with 27 additions and 3 deletions
|
@ -35,6 +35,7 @@ interface IState {
|
||||||
headerKind: HeaderKind;
|
headerKind: HeaderKind;
|
||||||
phase: RightPanelPhases;
|
phase: RightPanelPhases;
|
||||||
threadNotificationColor: NotificationColor;
|
threadNotificationColor: NotificationColor;
|
||||||
|
globalNotificationColor: NotificationColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IProps {}
|
interface IProps {}
|
||||||
|
@ -51,6 +52,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
|
||||||
headerKind: kind,
|
headerKind: kind,
|
||||||
phase: rps.currentCard.phase,
|
phase: rps.currentCard.phase,
|
||||||
threadNotificationColor: NotificationColor.None,
|
threadNotificationColor: NotificationColor.None,
|
||||||
|
globalNotificationColor: NotificationColor.None,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,13 @@ import { useSettingValue } from "../../../hooks/useSettings";
|
||||||
import { useReadPinnedEvents, usePinnedEvents } from './PinnedMessagesCard';
|
import { useReadPinnedEvents, usePinnedEvents } from './PinnedMessagesCard';
|
||||||
import { showThreadPanel } from "../../../dispatcher/dispatch-actions/threads";
|
import { showThreadPanel } from "../../../dispatcher/dispatch-actions/threads";
|
||||||
import SettingsStore from "../../../settings/SettingsStore";
|
import SettingsStore from "../../../settings/SettingsStore";
|
||||||
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
|
import {
|
||||||
|
RoomNotificationStateStore,
|
||||||
|
UPDATE_STATUS_INDICATOR,
|
||||||
|
} from "../../../stores/notifications/RoomNotificationStateStore";
|
||||||
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
|
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
|
||||||
import { ThreadsRoomNotificationState } from "../../../stores/notifications/ThreadsRoomNotificationState";
|
import { ThreadsRoomNotificationState } from "../../../stores/notifications/ThreadsRoomNotificationState";
|
||||||
|
import { SummarizedNotificationState } from "../../../stores/notifications/SummarizedNotificationState";
|
||||||
import { NotificationStateEvents } from "../../../stores/notifications/NotificationState";
|
import { NotificationStateEvents } from "../../../stores/notifications/NotificationState";
|
||||||
import PosthogTrackers from "../../../PosthogTrackers";
|
import PosthogTrackers from "../../../PosthogTrackers";
|
||||||
import { ButtonEvent } from "../elements/AccessibleButton";
|
import { ButtonEvent } from "../elements/AccessibleButton";
|
||||||
|
@ -130,29 +134,42 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
||||||
RightPanelPhases.ThreadView,
|
RightPanelPhases.ThreadView,
|
||||||
];
|
];
|
||||||
private threadNotificationState: ThreadsRoomNotificationState;
|
private threadNotificationState: ThreadsRoomNotificationState;
|
||||||
|
private globalNotificationState: SummarizedNotificationState;
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
super(props, HeaderKind.Room);
|
super(props, HeaderKind.Room);
|
||||||
|
|
||||||
this.threadNotificationState = RoomNotificationStateStore.instance.getThreadsRoomState(this.props.room);
|
this.threadNotificationState = RoomNotificationStateStore.instance.getThreadsRoomState(this.props.room);
|
||||||
|
this.globalNotificationState = RoomNotificationStateStore.instance.globalState;
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidMount(): void {
|
public componentDidMount(): void {
|
||||||
super.componentDidMount();
|
super.componentDidMount();
|
||||||
this.threadNotificationState.on(NotificationStateEvents.Update, this.onThreadNotification);
|
this.threadNotificationState.on(NotificationStateEvents.Update, this.onThreadNotification);
|
||||||
|
RoomNotificationStateStore.instance.on(UPDATE_STATUS_INDICATOR, this.onUpdateStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount(): void {
|
public componentWillUnmount(): void {
|
||||||
super.componentWillUnmount();
|
super.componentWillUnmount();
|
||||||
this.threadNotificationState.off(NotificationStateEvents.Update, this.onThreadNotification);
|
this.threadNotificationState.off(NotificationStateEvents.Update, this.onThreadNotification);
|
||||||
|
RoomNotificationStateStore.instance.off(UPDATE_STATUS_INDICATOR, this.onUpdateStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
private onThreadNotification = (): void => {
|
private onThreadNotification = (): void => {
|
||||||
|
// XXX: why don't we read from this.state.threadNotificationColor in the render methods?
|
||||||
this.setState({
|
this.setState({
|
||||||
threadNotificationColor: this.threadNotificationState.color,
|
threadNotificationColor: this.threadNotificationState.color,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private onUpdateStatus = (notificationState: SummarizedNotificationState): void => {
|
||||||
|
// XXX: why don't we read from this.state.globalNotificationCount in the render methods?
|
||||||
|
this.globalNotificationState = notificationState;
|
||||||
|
this.setState({
|
||||||
|
globalNotificationColor: notificationState.color,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
protected onAction(payload: ActionPayload) {
|
protected onAction(payload: ActionPayload) {
|
||||||
if (payload.action === Action.ViewUser) {
|
if (payload.action === Action.ViewUser) {
|
||||||
if (payload.member) {
|
if (payload.member) {
|
||||||
|
@ -254,7 +271,12 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
||||||
title={_t('Notifications')}
|
title={_t('Notifications')}
|
||||||
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
|
||||||
onClick={this.onNotificationsClicked}
|
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,
|
rightPanelPhaseButtons.set(RightPanelPhases.RoomSummary,
|
||||||
<HeaderButton
|
<HeaderButton
|
||||||
|
@ -269,7 +291,7 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
|
||||||
return <>
|
return <>
|
||||||
{
|
{
|
||||||
Array.from(rightPanelPhaseButtons.keys()).map((phase) =>
|
Array.from(rightPanelPhaseButtons.keys()).map((phase) =>
|
||||||
(this.props.excludedRightPanelPhaseButtons.includes(phase)
|
(this.props.excludedRightPanelPhaseButtons?.includes(phase)
|
||||||
? null
|
? null
|
||||||
: rightPanelPhaseButtons.get(phase)))
|
: rightPanelPhaseButtons.get(phase)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue