mirror of
https://github.com/ulyssa/iamb.git
synced 2024-09-11 11:55:48 +03:00
Merge 20a248e36b
into c6982c9737
This commit is contained in:
commit
67b851f4de
@ -1319,6 +1319,9 @@ pub struct ChatStore {
|
|||||||
|
|
||||||
/// Whether to ring the terminal bell on the next redraw.
|
/// Whether to ring the terminal bell on the next redraw.
|
||||||
pub ring_bell: bool,
|
pub ring_bell: bool,
|
||||||
|
|
||||||
|
/// Whether the application is currently focused
|
||||||
|
pub focused: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ChatStore {
|
impl ChatStore {
|
||||||
@ -1341,6 +1344,7 @@ impl ChatStore {
|
|||||||
sync_info: Default::default(),
|
sync_info: Default::default(),
|
||||||
draw_curr: None,
|
draw_curr: None,
|
||||||
ring_bell: false,
|
ring_bell: false,
|
||||||
|
focused: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,9 +355,13 @@ impl Application {
|
|||||||
// Do nothing for now.
|
// Do nothing for now.
|
||||||
},
|
},
|
||||||
Event::FocusGained => {
|
Event::FocusGained => {
|
||||||
|
let mut store = self.store.lock().await;
|
||||||
|
store.application.focused = true;
|
||||||
self.focused = true;
|
self.focused = true;
|
||||||
},
|
},
|
||||||
Event::FocusLost => {
|
Event::FocusLost => {
|
||||||
|
let mut store = self.store.lock().await;
|
||||||
|
store.application.focused = false;
|
||||||
self.focused = false;
|
self.focused = false;
|
||||||
},
|
},
|
||||||
Event::Resize(_, _) => {
|
Event::Resize(_, _) => {
|
||||||
|
@ -44,7 +44,7 @@ pub async fn register_notifications(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_open(&store, room.room_id()).await {
|
if is_focused(&store).await && is_open(&store, room.room_id()).await {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,6 +139,11 @@ async fn is_open(store: &AsyncProgramStore, room_id: &RoomId) -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn is_focused(store: &AsyncProgramStore) -> bool {
|
||||||
|
let locked = store.lock().await;
|
||||||
|
locked.application.focused
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn parse_notification(
|
pub async fn parse_notification(
|
||||||
notification: Notification,
|
notification: Notification,
|
||||||
room: MatrixRoom,
|
room: MatrixRoom,
|
||||||
|
Loading…
Reference in New Issue
Block a user