diff --git a/src/window.rs b/src/window.rs index ea1efac..a863fdb 100644 --- a/src/window.rs +++ b/src/window.rs @@ -246,10 +246,12 @@ pub mod imp { } fn on_article_selected(&self, obj: ArticleObject) { - // Mark previous article as read (unless guard is set) + // Mark the previous article as read — both on the server and in the + // sidebar — now that the user has navigated away from it. if !*self.mark_unread_guard.borrow() { if let Some(prev_id) = self.current_article_id.borrow().clone() { if prev_id != obj.article().id { + self.mark_read_in_list(&prev_id); self.bg_mark_read(prev_id); } } @@ -267,7 +269,20 @@ pub mod imp { if !same_article { self.load_article_in_webview(&article); } - obj.set_unread(false); + } + + /// Mark an article as read in the sidebar list (UI only). + fn mark_read_in_list(&self, article_id: &str) { + if let Some(store) = self.article_store.borrow().as_ref() { + for i in 0..store.n_items() { + if let Some(obj) = store.item(i).and_downcast::() { + if obj.article().id == article_id { + obj.set_unread(false); + break; + } + } + } + } } fn reload_current_article(&self) {