feat(web): remove more button when tl is over

This commit is contained in:
əlemi 2024-04-23 23:37:39 +02:00
parent 8969780b29
commit e9c765b555
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -8,18 +8,21 @@ use crate::prelude::*;
pub struct Timeline { pub struct Timeline {
pub feed: RwSignal<Vec<String>>, pub feed: RwSignal<Vec<String>>,
pub next: RwSignal<String>, pub next: RwSignal<String>,
pub over: RwSignal<bool>,
} }
impl Timeline { impl Timeline {
pub fn new(url: String) -> Self { pub fn new(url: String) -> Self {
let feed = create_rw_signal(vec![]); let feed = create_rw_signal(vec![]);
let next = create_rw_signal(url); let next = create_rw_signal(url);
Timeline { feed, next } let over = create_rw_signal(false);
Timeline { feed, next, over }
} }
pub fn reset(&self, url: String) { pub fn reset(&self, url: String) {
self.feed.set(vec![]); self.feed.set(vec![]);
self.next.set(url); self.next.set(url);
self.over.set(false);
} }
pub async fn more(&self, auth: Signal<Option<String>>) -> reqwest::Result<()> { pub async fn more(&self, auth: Signal<Option<String>>) -> reqwest::Result<()> {
@ -38,6 +41,8 @@ impl Timeline {
if let Some(next) = collection.next().id() { if let Some(next) = collection.next().id() {
self.next.set(next); self.next.set(next);
} else {
self.over.set(true);
} }
Ok(()) Ok(())
@ -157,7 +162,7 @@ pub fn TimelineFeed(tl: Timeline) -> impl IntoView {
} }
} }
/ > / >
<div class="center mt-1 mb-1" > <div class="center mt-1 mb-1" class:hidden=tl.over>
<button type="button" <button type="button"
on:click=move |_| { on:click=move |_| {
spawn_local(async move { spawn_local(async move {