@@ -22,7 +22,6 @@ import React from "react";
2222import classNames from "classnames" ;
2323import { NotificationCountType , Room , RoomEvent } from "matrix-js-sdk/src/models/room" ;
2424import { ThreadEvent } from "matrix-js-sdk/src/models/thread" ;
25- import { Feature , ServerSupport } from "matrix-js-sdk/src/feature" ;
2625
2726import { _t } from "../../../languageHandler" ;
2827import HeaderButton from "./HeaderButton" ;
@@ -39,12 +38,9 @@ import {
3938 UPDATE_STATUS_INDICATOR ,
4039} from "../../../stores/notifications/RoomNotificationStateStore" ;
4140import { NotificationColor } from "../../../stores/notifications/NotificationColor" ;
42- import { ThreadsRoomNotificationState } from "../../../stores/notifications/ThreadsRoomNotificationState" ;
4341import { SummarizedNotificationState } from "../../../stores/notifications/SummarizedNotificationState" ;
44- import { NotificationStateEvents } from "../../../stores/notifications/NotificationState" ;
4542import PosthogTrackers from "../../../PosthogTrackers" ;
4643import { ButtonEvent } from "../elements/AccessibleButton" ;
47- import { MatrixClientPeg } from "../../../MatrixClientPeg" ;
4844import { doesRoomOrThreadHaveUnreadMessages } from "../../../Unread" ;
4945
5046const ROOM_INFO_PHASES = [
@@ -133,74 +129,48 @@ interface IProps {
133129
134130export default class RoomHeaderButtons extends HeaderButtons < IProps > {
135131 private static readonly THREAD_PHASES = [ RightPanelPhases . ThreadPanel , RightPanelPhases . ThreadView ] ;
136- private threadNotificationState : ThreadsRoomNotificationState | null ;
137132 private globalNotificationState : SummarizedNotificationState ;
138133
139- private get supportsThreadNotifications ( ) : boolean {
140- const client = MatrixClientPeg . get ( ) ;
141- return client . canSupport . get ( Feature . ThreadUnreadNotifications ) !== ServerSupport . Unsupported ;
142- }
143-
144134 public constructor ( props : IProps ) {
145135 super ( props , HeaderKind . Room ) ;
146-
147- this . threadNotificationState =
148- ! this . supportsThreadNotifications && this . props . room
149- ? RoomNotificationStateStore . instance . getThreadsRoomState ( this . props . room )
150- : null ;
151136 this . globalNotificationState = RoomNotificationStateStore . instance . globalState ;
152137 }
153138
154139 public componentDidMount ( ) : void {
155140 super . componentDidMount ( ) ;
156- if ( ! this . supportsThreadNotifications ) {
157- this . threadNotificationState ?. on ( NotificationStateEvents . Update , this . onNotificationUpdate ) ;
158- } else {
159- // Notification badge may change if the notification counts from the
160- // server change, if a new thread is created or updated, or if a
161- // receipt is sent in the thread.
162- this . props . room ?. on ( RoomEvent . UnreadNotifications , this . onNotificationUpdate ) ;
163- this . props . room ?. on ( RoomEvent . Receipt , this . onNotificationUpdate ) ;
164- this . props . room ?. on ( RoomEvent . Timeline , this . onNotificationUpdate ) ;
165- this . props . room ?. on ( RoomEvent . Redaction , this . onNotificationUpdate ) ;
166- this . props . room ?. on ( RoomEvent . LocalEchoUpdated , this . onNotificationUpdate ) ;
167- this . props . room ?. on ( RoomEvent . MyMembership , this . onNotificationUpdate ) ;
168- this . props . room ?. on ( ThreadEvent . New , this . onNotificationUpdate ) ;
169- this . props . room ?. on ( ThreadEvent . Update , this . onNotificationUpdate ) ;
170- }
141+ // Notification badge may change if the notification counts from the
142+ // server change, if a new thread is created or updated, or if a
143+ // receipt is sent in the thread.
144+ this . props . room ?. on ( RoomEvent . UnreadNotifications , this . onNotificationUpdate ) ;
145+ this . props . room ?. on ( RoomEvent . Receipt , this . onNotificationUpdate ) ;
146+ this . props . room ?. on ( RoomEvent . Timeline , this . onNotificationUpdate ) ;
147+ this . props . room ?. on ( RoomEvent . Redaction , this . onNotificationUpdate ) ;
148+ this . props . room ?. on ( RoomEvent . LocalEchoUpdated , this . onNotificationUpdate ) ;
149+ this . props . room ?. on ( RoomEvent . MyMembership , this . onNotificationUpdate ) ;
150+ this . props . room ?. on ( ThreadEvent . New , this . onNotificationUpdate ) ;
151+ this . props . room ?. on ( ThreadEvent . Update , this . onNotificationUpdate ) ;
171152 this . onNotificationUpdate ( ) ;
172153 RoomNotificationStateStore . instance . on ( UPDATE_STATUS_INDICATOR , this . onUpdateStatus ) ;
173154 }
174155
175156 public componentWillUnmount ( ) : void {
176157 super . componentWillUnmount ( ) ;
177- if ( ! this . supportsThreadNotifications ) {
178- this . threadNotificationState ?. off ( NotificationStateEvents . Update , this . onNotificationUpdate ) ;
179- } else {
180- this . props . room ?. off ( RoomEvent . UnreadNotifications , this . onNotificationUpdate ) ;
181- this . props . room ?. off ( RoomEvent . Receipt , this . onNotificationUpdate ) ;
182- this . props . room ?. off ( RoomEvent . Timeline , this . onNotificationUpdate ) ;
183- this . props . room ?. off ( RoomEvent . Redaction , this . onNotificationUpdate ) ;
184- this . props . room ?. off ( RoomEvent . LocalEchoUpdated , this . onNotificationUpdate ) ;
185- this . props . room ?. off ( RoomEvent . MyMembership , this . onNotificationUpdate ) ;
186- this . props . room ?. off ( ThreadEvent . New , this . onNotificationUpdate ) ;
187- this . props . room ?. off ( ThreadEvent . Update , this . onNotificationUpdate ) ;
188- }
158+ this . props . room ?. off ( RoomEvent . UnreadNotifications , this . onNotificationUpdate ) ;
159+ this . props . room ?. off ( RoomEvent . Receipt , this . onNotificationUpdate ) ;
160+ this . props . room ?. off ( RoomEvent . Timeline , this . onNotificationUpdate ) ;
161+ this . props . room ?. off ( RoomEvent . Redaction , this . onNotificationUpdate ) ;
162+ this . props . room ?. off ( RoomEvent . LocalEchoUpdated , this . onNotificationUpdate ) ;
163+ this . props . room ?. off ( RoomEvent . MyMembership , this . onNotificationUpdate ) ;
164+ this . props . room ?. off ( ThreadEvent . New , this . onNotificationUpdate ) ;
165+ this . props . room ?. off ( ThreadEvent . Update , this . onNotificationUpdate ) ;
189166 RoomNotificationStateStore . instance . off ( UPDATE_STATUS_INDICATOR , this . onUpdateStatus ) ;
190167 }
191168
192169 private onNotificationUpdate = ( ) : void => {
193- let threadNotificationColor : NotificationColor ;
194- if ( ! this . supportsThreadNotifications ) {
195- threadNotificationColor = this . threadNotificationState ?. color ?? NotificationColor . None ;
196- } else {
197- threadNotificationColor = this . notificationColor ;
198- }
199-
200170 // console.log
201171 // XXX: why don't we read from this.state.threadNotificationColor in the render methods?
202172 this . setState ( {
203- threadNotificationColor,
173+ threadNotificationColor : this . notificationColor ,
204174 } ) ;
205175 } ;
206176
0 commit comments