Skip to content

Commit

Permalink
[*] fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed May 19, 2024
1 parent efbe713 commit 47f7ffd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 5 deletions.
5 changes: 5 additions & 0 deletions src/logic/rss.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Logic>().on_load_all_rss(move || {
init_rss(&ui_handle.unwrap());
});

let ui_handle = ui.as_weak();
ui.global::<Logic>().on_new_rss(move |config| {
let ui = ui_handle.unwrap();
Expand Down
3 changes: 3 additions & 0 deletions ui/logic.slint
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 14 additions & 5 deletions ui/panel/bodyer/rss.slint
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export component Entry inherits Rectangle {
in-out property <string> suuid;
in-out property <string> 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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -278,13 +278,13 @@ export component EntryList inherits Rectangle {
private property <bool> is-show-opt: false;
private property <bool> 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;
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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);
}
}
Expand All @@ -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();
}

Expand All @@ -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 => {
Expand Down
4 changes: 4 additions & 0 deletions ui/panel/footer.slint
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 2 additions & 0 deletions ui/store.slint
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
},
Expand Down

0 comments on commit 47f7ffd

Please sign in to comment.