feat(web): explicit button to fetch replies

This commit is contained in:
əlemi 2024-11-10 22:06:13 +01:00
parent 187a659608
commit 80940b1880
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 13 additions and 3 deletions

View file

@ -41,9 +41,22 @@ pub fn ObjectView() -> impl IntoView {
<hr class="color ma-2" /> <hr class="color ma-2" />
<code class="cw color center mt-1 mb-1 ml-3 mr-3"> <code class="cw color center mt-1 mb-1 ml-3 mr-3">
<a class="clean" href=format!("{base}/context")><span class="emoji">"🕸️"</span>" "<b>context</b></a>" | "<a class="clean" href=format!("{base}/replies")><span class="emoji">"📫"</span>" "<b>replies</b></a> <a class="clean" href=format!("{base}/context")><span class="emoji">"🕸️"</span>" "<b>context</b></a>" | "<a class="clean" href=format!("{base}/replies")><span class="emoji">"📫"</span>" "<b>replies</b></a>
{if auth.present() {
Some(view! {
" | "<a class="clean" href="#crawl" on:click=move |_| crawl(base.clone(), auth) ><span class="emoji">""</span></a>
})
} else { None }}
</code> </code>
<Outlet /> <Outlet />
}.into_view() }.into_view()
}, },
}} }}
} }
fn crawl(base: String, auth: Auth) {
spawn_local(async move {
if let Err(e) = Http::fetch::<serde_json::Value>(&format!("{base}/replies?fetch=true"), auth).await {
tracing::error!("failed crawling replies for {base}: {e}");
}
});
}

View file

@ -84,9 +84,6 @@ impl Timeline {
feed_url + "?replies=false" feed_url + "?replies=false"
}; };
} }
if auth.present() {
feed_url += "&fetch=true";
}
let collection : serde_json::Value = Http::fetch(&feed_url, auth).await?; let collection : serde_json::Value = Http::fetch(&feed_url, auth).await?;
let activities : Vec<serde_json::Value> = collection let activities : Vec<serde_json::Value> = collection
.ordered_items() .ordered_items()