From 41312f48f3b96085735b3c276b554806b113ced6 Mon Sep 17 00:00:00 2001 From: Jeena Date: Sat, 28 Mar 2026 22:57:04 +0000 Subject: [PATCH] window: only mark articles as read when navigating away Previously the sidebar immediately showed an article as read the moment it was selected, while the server was only notified when the user moved to the next article. Align the two: mark the previous article as read in both the sidebar and on the server at the same time, when the user navigates away from it. --- src/window.rs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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) {