From 47f7ffd554b3d904cbf3e60de51320b5f4f3918d Mon Sep 17 00:00:00 2001 From: blueJpg <2238288979@qq.com> Date: Sun, 19 May 2024 14:04:16 +0800 Subject: [PATCH] [*] fixed bug --- src/logic/rss.rs | 5 +++++ ui/logic.slint | 3 +++ ui/panel/bodyer/rss.slint | 19 ++++++++++++++----- ui/panel/footer.slint | 4 ++++ ui/store.slint | 2 ++ 5 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/logic/rss.rs b/src/logic/rss.rs index 88951f0..ac08120 100644 --- a/src/logic/rss.rs +++ b/src/logic/rss.rs @@ -260,6 +260,11 @@ pub fn init_rss(ui: &AppWindow) { pub fn init(ui: &AppWindow) { init_rss(ui); + let ui_handle = ui.as_weak(); + ui.global::().on_load_all_rss(move || { + init_rss(&ui_handle.unwrap()); + }); + let ui_handle = ui.as_weak(); ui.global::().on_new_rss(move |config| { let ui = ui_handle.unwrap(); diff --git a/ui/logic.slint b/ui/logic.slint index c4dad47..c328084 100644 --- a/ui/logic.slint +++ b/ui/logic.slint @@ -1,6 +1,9 @@ import { RssConfig, RssEntry, SettingUI, SettingReading, SettingSync, SettingProxy, SettingBackupRecover, SettingUpdate } from "./store.slint"; export global Logic { + // when it should be called. The app stay in background for a long time, and killed by the system. After that, restart the app will not load the rss from the database. so we should call it manually. + callback load-all-rss(); + callback new-rss(RssConfig); callback update-rss(string, RssConfig); callback remove-rss(string); // suuid diff --git a/ui/panel/bodyer/rss.slint b/ui/panel/bodyer/rss.slint index 1799b8d..a7ddd40 100644 --- a/ui/panel/bodyer/rss.slint +++ b/ui/panel/bodyer/rss.slint @@ -208,7 +208,7 @@ export component Entry inherits Rectangle { in-out property suuid; in-out property url; - background: Theme.base-background; + background: Theme.base-background; border-radius: Theme.border-radius; drop-shadow-blur: Theme.padding * 2; drop-shadow-color: Theme.base-background-drop-shadow; @@ -264,7 +264,7 @@ export component Entry inherits Rectangle { export component EntryList inherits Rectangle { clip: true; - public function scroll-to-top(){ + public function scroll-to-top() { lv.viewport-y = 0; } @@ -278,13 +278,13 @@ export component EntryList inherits Rectangle { private property is-show-opt: false; private property is-hide-opt: true; - public function show-opt(){ + public function show-opt() { rect.x = -opt.width - Theme.padding; rect.is-show-opt = true; rect.is-hide-opt = false; } - public function hide-opt(){ + public function hide-opt() { rect.x = 0; rect.is-hide-opt = true; rect.is-show-opt = false; @@ -392,6 +392,9 @@ export component EntryList inherits Rectangle { icon: Icons.menu; clicked => { + if (Store.rss-lists.length == 0) { + Logic.load-all-rss(); + } Store.is-show-side-rsslist = true; } } @@ -401,6 +404,9 @@ export component EntryList inherits Rectangle { enable-rotation-animation: true; clicked => { + if (Store.rss-lists.length == 0) { + Logic.load-all-rss(); + } Logic.sync-rss(Store.current-rss-uuid, true); } } @@ -410,7 +416,7 @@ export component EntryList inherits Rectangle { component Body inherits Rectangle { in-out property is-show-rsslist <=> rsslist.is-show-list; - public function entrylist-scroll-to-top(){ + public function entrylist-scroll-to-top() { entrylist.scroll-to-top(); } @@ -422,6 +428,9 @@ component Body inherits Rectangle { export component Rss inherits VerticalLayout { head := RHead { clicked => { + if (Store.rss-lists.length == 0) { + Logic.load-all-rss(); + } body.is-show-rsslist = !body.is-show-rsslist; } scroll-to-top => { diff --git a/ui/panel/footer.slint b/ui/panel/footer.slint index 091be38..0a32e26 100644 --- a/ui/panel/footer.slint +++ b/ui/panel/footer.slint @@ -27,6 +27,10 @@ export component Footer inherits Rectangle { clicked => { if (self.checked) { Store.is-show-side-rsslist = !Store.is-show-side-rsslist; + + if (Store.is-show-side-rsslist && Store.rss-lists.length == 0) { + Logic.load-all-rss(); + } } Store.switch-tab(TabIndex.Rss); } diff --git a/ui/store.slint b/ui/store.slint index 669d0f6..cadf768 100644 --- a/ui/store.slint +++ b/ui/store.slint @@ -125,6 +125,8 @@ export global Store { tags: "rust", is-read: false, author: "hello", + summary: "The actor model in computer science is a mathematical model of concurrent computation that treats an actor as the basic building block of concurrent computation.", + // title: "Actors ", title: "Actors may modify their own private state, but can only affect each other indirectly through messaging (removing the need for lock-based synchronization).", summary: "The actor model in computer science is a mathematical model of concurrent computation that treats an actor as the basic building block of concurrent computation.", },