From f6ba30a43ff64f70f8703a2659289c45bdd09d1a Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 29 Apr 2024 02:53:33 +0200 Subject: [PATCH] feat(web): show when tl is loading, disable btn --- web/src/components/timeline.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs index 40d551d6..a934cc82 100644 --- a/web/src/components/timeline.rs +++ b/web/src/components/timeline.rs @@ -9,6 +9,7 @@ pub struct Timeline { pub feed: RwSignal>, pub next: RwSignal, pub over: RwSignal, + pub loading: RwSignal, } impl Timeline { @@ -16,7 +17,8 @@ impl Timeline { let feed = create_rw_signal(vec![]); let next = create_rw_signal(url); let over = create_rw_signal(false); - Timeline { feed, next, over } + let loading = create_rw_signal(false); + Timeline { feed, next, over, loading } } pub fn reset(&self, url: String) { @@ -26,6 +28,13 @@ impl Timeline { } pub async fn more(&self, auth: Signal>) -> reqwest::Result<()> { + self.loading.set(true); + let res = self.more_inner(auth).await; + self.loading.set(false); + res + } + + async fn more_inner(&self, auth: Signal>) -> reqwest::Result<()> { use apb::{Collection, CollectionPage}; let feed_url = self.next.get(); @@ -121,6 +130,7 @@ pub fn TimelineReplies(tl: Timeline, root: String) -> impl IntoView {
+ >{move || if tl.loading.get() { "loading" } else { "more" }}
} } @@ -177,8 +187,9 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView { } } / > -
+
+ >{move || if tl.loading.get() { "loading" } else { "more" }}
} }