Commit f0afadcc authored by Eisha Chen-yen-su's avatar Eisha Chen-yen-su

app.rs: Mark messages when window focused

This adds the method `mark_active_room_messages` which is called when
the window is focused.

Fixes https://gitlab.gnome.org/danigm/fractal/issues/102
parent ce47042b
......@@ -1196,6 +1196,23 @@ impl AppOp {
}
}
pub fn mark_active_room_messages(&mut self) {
if let Some(active_room_id) = self.active_room.clone() {
let mut room = None;
if let Some(r) = self.rooms.get(&active_room_id) {
room = Some(r.clone());
}
if let Some(r) = room {
if !r.messages.is_empty() {
if let Some(msg) = r.messages.iter().last() {
self.mark_as_read(msg);
}
}
}
}
}
pub fn set_room_detail(&mut self, roomid: String, key: String, value: Option<String>) {
if let Some(r) = self.rooms.get_mut(&roomid) {
let k: &str = &key;
......@@ -2673,6 +2690,13 @@ impl App {
}
});
let op = self.op.clone();
window.connect_property_has_toplevel_focus_notify(move |w| {
if !w.is_active() {
op.lock().unwrap().mark_active_room_messages();
}
});
self.create_load_more_btn();
self.connect_more_members_btn();
self.create_actions();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment