@@ -22,7 +22,6 @@ import React from "react";
22
22
import classNames from "classnames" ;
23
23
import { NotificationCountType , Room , RoomEvent } from "matrix-js-sdk/src/models/room" ;
24
24
import { ThreadEvent } from "matrix-js-sdk/src/models/thread" ;
25
- import { Feature , ServerSupport } from "matrix-js-sdk/src/feature" ;
26
25
27
26
import { _t } from "../../../languageHandler" ;
28
27
import HeaderButton from "./HeaderButton" ;
@@ -39,12 +38,9 @@ import {
39
38
UPDATE_STATUS_INDICATOR ,
40
39
} from "../../../stores/notifications/RoomNotificationStateStore" ;
41
40
import { NotificationColor } from "../../../stores/notifications/NotificationColor" ;
42
- import { ThreadsRoomNotificationState } from "../../../stores/notifications/ThreadsRoomNotificationState" ;
43
41
import { SummarizedNotificationState } from "../../../stores/notifications/SummarizedNotificationState" ;
44
- import { NotificationStateEvents } from "../../../stores/notifications/NotificationState" ;
45
42
import PosthogTrackers from "../../../PosthogTrackers" ;
46
43
import { ButtonEvent } from "../elements/AccessibleButton" ;
47
- import { MatrixClientPeg } from "../../../MatrixClientPeg" ;
48
44
import { doesRoomOrThreadHaveUnreadMessages } from "../../../Unread" ;
49
45
50
46
const ROOM_INFO_PHASES = [
@@ -133,74 +129,48 @@ interface IProps {
133
129
134
130
export default class RoomHeaderButtons extends HeaderButtons < IProps > {
135
131
private static readonly THREAD_PHASES = [ RightPanelPhases . ThreadPanel , RightPanelPhases . ThreadView ] ;
136
- private threadNotificationState : ThreadsRoomNotificationState | null ;
137
132
private globalNotificationState : SummarizedNotificationState ;
138
133
139
- private get supportsThreadNotifications ( ) : boolean {
140
- const client = MatrixClientPeg . get ( ) ;
141
- return client . canSupport . get ( Feature . ThreadUnreadNotifications ) !== ServerSupport . Unsupported ;
142
- }
143
-
144
134
public constructor ( props : IProps ) {
145
135
super ( props , HeaderKind . Room ) ;
146
-
147
- this . threadNotificationState =
148
- ! this . supportsThreadNotifications && this . props . room
149
- ? RoomNotificationStateStore . instance . getThreadsRoomState ( this . props . room )
150
- : null ;
151
136
this . globalNotificationState = RoomNotificationStateStore . instance . globalState ;
152
137
}
153
138
154
139
public componentDidMount ( ) : void {
155
140
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 ) ;
171
152
this . onNotificationUpdate ( ) ;
172
153
RoomNotificationStateStore . instance . on ( UPDATE_STATUS_INDICATOR , this . onUpdateStatus ) ;
173
154
}
174
155
175
156
public componentWillUnmount ( ) : void {
176
157
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 ) ;
189
166
RoomNotificationStateStore . instance . off ( UPDATE_STATUS_INDICATOR , this . onUpdateStatus ) ;
190
167
}
191
168
192
169
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
-
200
170
// console.log
201
171
// XXX: why don't we read from this.state.threadNotificationColor in the render methods?
202
172
this . setState ( {
203
- threadNotificationColor,
173
+ threadNotificationColor : this . notificationColor ,
204
174
} ) ;
205
175
} ;
206
176
0 commit comments