@@ -25,17 +25,21 @@ import { EffectiveMembership, getEffectiveMembership } from "../../utils/members
2525import { readReceiptChangeIsFor } from "../../utils/read-receipts" ;
2626import * as RoomNotifs from '../../RoomNotifs' ;
2727import * as Unread from '../../Unread' ;
28- import { NotificationState } from "./NotificationState" ;
28+ import { NotificationState , NotificationStateEvents } from "./NotificationState" ;
2929import { getUnsentMessages } from "../../components/structures/RoomStatusBar" ;
30+ import { ThreadsRoomNotificationState } from "./ThreadsRoomNotificationState" ;
3031
3132export class RoomNotificationState extends NotificationState implements IDestroyable {
32- constructor ( public readonly room : Room ) {
33+ constructor ( public readonly room : Room , private readonly threadsState ?: ThreadsRoomNotificationState ) {
3334 super ( ) ;
3435 this . room . on ( RoomEvent . Receipt , this . handleReadReceipt ) ;
3536 this . room . on ( RoomEvent . Timeline , this . handleRoomEventUpdate ) ;
3637 this . room . on ( RoomEvent . Redaction , this . handleRoomEventUpdate ) ;
3738 this . room . on ( RoomEvent . MyMembership , this . handleMembershipUpdate ) ;
3839 this . room . on ( RoomEvent . LocalEchoUpdated , this . handleLocalEchoUpdated ) ;
40+ if ( threadsState ) {
41+ threadsState . on ( NotificationStateEvents . Update , this . handleThreadsUpdate ) ;
42+ }
3943 MatrixClientPeg . get ( ) . on ( MatrixEventEvent . Decrypted , this . onEventDecrypted ) ;
4044 MatrixClientPeg . get ( ) . on ( ClientEvent . AccountData , this . handleAccountDataUpdate ) ;
4145 this . updateNotificationState ( ) ;
@@ -52,12 +56,19 @@ export class RoomNotificationState extends NotificationState implements IDestroy
5256 this . room . removeListener ( RoomEvent . Redaction , this . handleRoomEventUpdate ) ;
5357 this . room . removeListener ( RoomEvent . MyMembership , this . handleMembershipUpdate ) ;
5458 this . room . removeListener ( RoomEvent . LocalEchoUpdated , this . handleLocalEchoUpdated ) ;
59+ if ( this . threadsState ) {
60+ this . threadsState . removeListener ( NotificationStateEvents . Update , this . handleThreadsUpdate ) ;
61+ }
5562 if ( MatrixClientPeg . get ( ) ) {
5663 MatrixClientPeg . get ( ) . removeListener ( MatrixEventEvent . Decrypted , this . onEventDecrypted ) ;
5764 MatrixClientPeg . get ( ) . removeListener ( ClientEvent . AccountData , this . handleAccountDataUpdate ) ;
5865 }
5966 }
6067
68+ private handleThreadsUpdate = ( ) => {
69+ this . updateNotificationState ( ) ;
70+ } ;
71+
6172 private handleLocalEchoUpdated = ( ) => {
6273 this . updateNotificationState ( ) ;
6374 } ;
0 commit comments