@@ -18,6 +18,7 @@ import { TypedEventEmitter } from "matrix-js-sdk/src/models/typed-event-emitter"
18
18
19
19
import { NotificationColor } from "./NotificationColor" ;
20
20
import { IDestroyable } from "../../utils/IDestroyable" ;
21
+ import SettingsStore from "../../settings/SettingsStore" ;
21
22
22
23
export interface INotificationStateSnapshotParams {
23
24
symbol : string | null ;
@@ -37,11 +38,22 @@ export abstract class NotificationState
37
38
extends TypedEventEmitter < NotificationStateEvents , EventHandlerMap >
38
39
implements INotificationStateSnapshotParams , IDestroyable {
39
40
//
40
- protected _symbol : string | null ;
41
- protected _count : number ;
42
- protected _color : NotificationColor ;
41
+ protected _symbol : string | null = null ;
42
+ protected _count = 0 ;
43
+ protected _color : NotificationColor = NotificationColor . None ;
44
+
45
+ private watcherReferences : string [ ] = [ ] ;
46
+
47
+ constructor ( ) {
48
+ super ( ) ;
49
+ this . watcherReferences . push (
50
+ SettingsStore . watchSetting ( "feature_hidebold" , null , ( ) => {
51
+ this . emit ( NotificationStateEvents . Update ) ;
52
+ } ) ,
53
+ ) ;
54
+ }
43
55
44
- public get symbol ( ) : string {
56
+ public get symbol ( ) : string | null {
45
57
return this . _symbol ;
46
58
}
47
59
@@ -58,7 +70,12 @@ export abstract class NotificationState
58
70
}
59
71
60
72
public get isUnread ( ) : boolean {
61
- return this . color >= NotificationColor . Bold ;
73
+ if ( this . color > NotificationColor . Bold ) {
74
+ return true ;
75
+ } else {
76
+ const hideBold = SettingsStore . getValue ( "feature_hidebold" ) ;
77
+ return this . color === NotificationColor . Bold && ! hideBold ;
78
+ }
62
79
}
63
80
64
81
public get hasUnreadCount ( ) : boolean {
@@ -81,11 +98,15 @@ export abstract class NotificationState
81
98
82
99
public destroy ( ) : void {
83
100
this . removeAllListeners ( NotificationStateEvents . Update ) ;
101
+ for ( const watcherReference of this . watcherReferences ) {
102
+ SettingsStore . unwatchSetting ( watcherReference ) ;
103
+ }
104
+ this . watcherReferences = [ ] ;
84
105
}
85
106
}
86
107
87
108
export class NotificationStateSnapshot {
88
- private readonly symbol : string ;
109
+ private readonly symbol : string | null ;
89
110
private readonly count : number ;
90
111
private readonly color : NotificationColor ;
91
112
0 commit comments