Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit eb97b96

Browse files
authored
add NotifPanel dot back. (#9242)
partially fixes element-hq/element-web#17641 provides a dot, but not a badge. fixes chronic bug 87.
1 parent 52fc8ff commit eb97b96

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/components/views/right_panel/HeaderButtons.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ interface IState {
3535
headerKind: HeaderKind;
3636
phase: RightPanelPhases;
3737
threadNotificationColor: NotificationColor;
38+
globalNotificationColor: NotificationColor;
3839
}
3940

4041
interface IProps {}
@@ -51,6 +52,7 @@ export default abstract class HeaderButtons<P = {}> extends React.Component<IPro
5152
headerKind: kind,
5253
phase: rps.currentCard.phase,
5354
threadNotificationColor: NotificationColor.None,
55+
globalNotificationColor: NotificationColor.None,
5456
};
5557
}
5658

src/components/views/right_panel/RoomHeaderButtons.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ import { useSettingValue } from "../../../hooks/useSettings";
3333
import { useReadPinnedEvents, usePinnedEvents } from './PinnedMessagesCard';
3434
import { showThreadPanel } from "../../../dispatcher/dispatch-actions/threads";
3535
import SettingsStore from "../../../settings/SettingsStore";
36-
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
36+
import {
37+
RoomNotificationStateStore,
38+
UPDATE_STATUS_INDICATOR,
39+
} from "../../../stores/notifications/RoomNotificationStateStore";
3740
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
3841
import { ThreadsRoomNotificationState } from "../../../stores/notifications/ThreadsRoomNotificationState";
42+
import { SummarizedNotificationState } from "../../../stores/notifications/SummarizedNotificationState";
3943
import { NotificationStateEvents } from "../../../stores/notifications/NotificationState";
4044
import PosthogTrackers from "../../../PosthogTrackers";
4145
import { ButtonEvent } from "../elements/AccessibleButton";
@@ -130,29 +134,42 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
130134
RightPanelPhases.ThreadView,
131135
];
132136
private threadNotificationState: ThreadsRoomNotificationState;
137+
private globalNotificationState: SummarizedNotificationState;
133138

134139
constructor(props: IProps) {
135140
super(props, HeaderKind.Room);
136141

137142
this.threadNotificationState = RoomNotificationStateStore.instance.getThreadsRoomState(this.props.room);
143+
this.globalNotificationState = RoomNotificationStateStore.instance.globalState;
138144
}
139145

140146
public componentDidMount(): void {
141147
super.componentDidMount();
142148
this.threadNotificationState.on(NotificationStateEvents.Update, this.onThreadNotification);
149+
RoomNotificationStateStore.instance.on(UPDATE_STATUS_INDICATOR, this.onUpdateStatus);
143150
}
144151

145152
public componentWillUnmount(): void {
146153
super.componentWillUnmount();
147154
this.threadNotificationState.off(NotificationStateEvents.Update, this.onThreadNotification);
155+
RoomNotificationStateStore.instance.off(UPDATE_STATUS_INDICATOR, this.onUpdateStatus);
148156
}
149157

150158
private onThreadNotification = (): void => {
159+
// XXX: why don't we read from this.state.threadNotificationColor in the render methods?
151160
this.setState({
152161
threadNotificationColor: this.threadNotificationState.color,
153162
});
154163
};
155164

165+
private onUpdateStatus = (notificationState: SummarizedNotificationState): void => {
166+
// XXX: why don't we read from this.state.globalNotificationCount in the render methods?
167+
this.globalNotificationState = notificationState;
168+
this.setState({
169+
globalNotificationColor: notificationState.color,
170+
});
171+
};
172+
156173
protected onAction(payload: ActionPayload) {
157174
if (payload.action === Action.ViewUser) {
158175
if (payload.member) {
@@ -254,7 +271,12 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
254271
title={_t('Notifications')}
255272
isHighlighted={this.isPhase(RightPanelPhases.NotificationPanel)}
256273
onClick={this.onNotificationsClicked}
257-
/>,
274+
isUnread={this.globalNotificationState.color === NotificationColor.Red}
275+
>
276+
{ this.globalNotificationState.color === NotificationColor.Red ?
277+
<UnreadIndicator color={this.globalNotificationState.color} /> :
278+
null }
279+
</HeaderButton>,
258280
);
259281
rightPanelPhaseButtons.set(RightPanelPhases.RoomSummary,
260282
<HeaderButton
@@ -269,7 +291,7 @@ export default class RoomHeaderButtons extends HeaderButtons<IProps> {
269291
return <>
270292
{
271293
Array.from(rightPanelPhaseButtons.keys()).map((phase) =>
272-
(this.props.excludedRightPanelPhaseButtons.includes(phase)
294+
(this.props.excludedRightPanelPhaseButtons?.includes(phase)
273295
? null
274296
: rightPanelPhaseButtons.get(phase)))
275297
}

0 commit comments

Comments
 (0)