From 668c73c8d2df3844770160cf3db91448d8485556 Mon Sep 17 00:00:00 2001 From: Jeena Date: Sat, 21 Mar 2026 03:05:19 +0000 Subject: [PATCH] window: show toast instead of login dialog when offline with cached articles --- src/window.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/window.rs b/src/window.rs index 64b5e7c..e0991ed 100644 --- a/src/window.rs +++ b/src/window.rs @@ -496,6 +496,7 @@ pub mod imp { } fn do_login(&self, server_url: String, username: String, password: String, store: bool) { + let is_auto = !store; let win_weak = self.obj().downgrade(); crate::runtime::spawn( async move { Api::login(&server_url, &username, &password).await @@ -525,8 +526,16 @@ pub mod imp { win.imp().fetch_articles(); } Err(e) => { - win.imp().show_login_dialog(); - win.imp().show_error_dialog("Login Failed", &e); + let has_cache = win.imp().article_store.borrow() + .as_ref().map(|s| s.n_items() > 0).unwrap_or(false); + if is_auto && has_cache { + // Offline with cached articles — just show a toast. + let toast = libadwaita::Toast::new("Offline — showing cached articles"); + win.imp().toast_overlay.add_toast(toast); + } else { + win.imp().show_login_dialog(); + win.imp().show_error_dialog("Login Failed", &e); + } } } },