window: persist article list and open article across restarts
On shutdown the full article list (including current read/unread state) and the ID of the open article are saved to ~/.local/share/net.jeena.FeedTheMonkey/cache.json. On next launch: - The cached articles are loaded into the list immediately, before any network request, so the sidebar is populated and the previously open article is visible without waiting for the server. - The article content is injected into the WebView once its base HTML finishes loading (LoadEvent::Finished), avoiding a race where window.setArticle() did not yet exist. - A background refresh then fetches fresh data from the server; if the previously open article still exists its selection is preserved, otherwise the first item is selected. - Network errors during a background refresh show a toast instead of replacing the visible article list with an error page.
This commit is contained in:
parent
8fd52dd8a0
commit
183191727b
4 changed files with 309 additions and 32 deletions
|
|
@ -3,7 +3,7 @@ use gtk4::prelude::*;
|
|||
use gtk4::subclass::prelude::*;
|
||||
use std::cell::RefCell;
|
||||
|
||||
#[derive(Debug, Clone, Default)]
|
||||
#[derive(Debug, Clone, Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Article {
|
||||
pub id: String,
|
||||
pub title: String,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue