From 58fe88457850cf13f9c97f551e7888a93c28a59c Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 9 Jan 2025 20:28:27 +0100 Subject: [PATCH] feat(web): fetch outbox button for actors too --- web/src/actors/header.rs | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/web/src/actors/header.rs b/web/src/actors/header.rs index ee9721e..180d17b 100644 --- a/web/src/actors/header.rs +++ b/web/src/actors/header.rs @@ -8,7 +8,10 @@ use apb::{ActivityMut, Actor, Base, Object, ObjectMut, Shortcuts}; pub fn ActorHeader() -> impl IntoView { let params = use_params::(); let auth = use_context::().expect("missing auth context"); + let config = use_context::>().expect("missing config context"); + let relevant_tl = use_context::>>().expect("missing relevant timeline context"); let matched_route = use_context::>().expect("missing route context"); + let (loading, set_loading) = create_signal(false); let actor = create_local_resource( move || params.get().ok().and_then(|x| x.id).unwrap_or_default(), move |id| { @@ -52,7 +55,9 @@ pub fn ActorHeader() -> impl IntoView { .collect_view(); let uid = actor.id().unwrap_or_default().to_string(); let web_path = Uri::web(U::Actor, &uid); + // TODO what the fuck... let _uid = uid.clone(); + let __uid = uid.clone(); view! {
impl IntoView { "👥"" following" + {move || if auth.present() { + if loading.get() { + Some(view! { + + "fetching " + + }) + } else { + let uid = __uid.clone(); + Some(view! { + + + "↺ ""fetch" + + + }) + } + } else { + None + }}


@@ -178,3 +207,16 @@ fn unfollow(target: String) { } }) } + +fn fetch_cb(ev: ev::MouseEvent, set_loading: WriteSignal, uid: String, auth: Auth, config: Signal, relevant_tl: Signal>) { + let api = Uri::api(U::Actor, &uid, false); + ev.prevent_default(); + set_loading.set(true); + spawn_local(async move { + if let Err(e) = Http::fetch::(&format!("{api}/outbox?fetch=true"), auth).await { + tracing::error!("failed fetching outbox for {uid}: {e}"); + } + set_loading.set(false); + relevant_tl.get().inspect(|x| x.refresh(auth, config)); + }); +}