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.
This commit is contained in:
Jeena 2026-03-28 22:57:04 +00:00
parent d39c7f824b
commit 41312f48f3

View file

@ -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::<ArticleObject>() {
if obj.article().id == article_id {
obj.set_unread(false);
break;
}
}
}
}
}
fn reload_current_article(&self) {