@@ -14,7 +14,7 @@ use matrix_sdk::{
14
14
use unicode_segmentation:: UnicodeSegmentation ;
15
15
16
16
use crate :: {
17
- base:: { AsyncProgramStore , IambError , IambResult } ,
17
+ base:: { AsyncProgramStore , IambError , IambResult , ProgramStore } ,
18
18
config:: { ApplicationSettings , NotifyVia } ,
19
19
} ;
20
20
@@ -44,7 +44,7 @@ pub async fn register_notifications(
44
44
return ;
45
45
}
46
46
47
- if is_open ( & store, room. room_id ( ) ) . await {
47
+ if is_visible_room ( & store, room. room_id ( ) ) . await {
48
48
return ;
49
49
}
50
50
@@ -127,8 +127,7 @@ fn is_missing_mention(body: &Option<String>, mode: RoomNotificationMode, client:
127
127
false
128
128
}
129
129
130
- async fn is_open ( store : & AsyncProgramStore , room_id : & RoomId ) -> bool {
131
- let mut locked = store. lock ( ) . await ;
130
+ fn is_open ( locked : & mut ProgramStore , room_id : & RoomId ) -> bool {
132
131
if let Some ( draw_curr) = locked. application . draw_curr {
133
132
let info = locked. application . get_room_info ( room_id. to_owned ( ) ) ;
134
133
if let Some ( draw_last) = info. draw_last {
@@ -138,6 +137,16 @@ async fn is_open(store: &AsyncProgramStore, room_id: &RoomId) -> bool {
138
137
false
139
138
}
140
139
140
+ fn is_focused ( locked : & ProgramStore ) -> bool {
141
+ locked. application . focused
142
+ }
143
+
144
+ async fn is_visible_room ( store : & AsyncProgramStore , room_id : & RoomId ) -> bool {
145
+ let mut locked = store. lock ( ) . await ;
146
+
147
+ is_focused ( & locked) && is_open ( & mut locked, room_id)
148
+ }
149
+
141
150
pub async fn parse_notification (
142
151
notification : Notification ,
143
152
room : MatrixRoom ,
0 commit comments