diff --git a/web/src/lib.rs b/web/src/lib.rs index ecf1d76..f3ad655 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -126,7 +126,7 @@ impl Uri { /// - https://other.domain.net/unexpected/path/root /// - +other.domain.net@users@root /// - root - pub fn api(kind: &str, url: &str) -> String { - format!("{URL_BASE}/{kind}/{}", Self::short(url)) + pub fn api(kind: &str, url: &str, fetch: bool) -> String { + format!("{URL_BASE}/{kind}/{}{}", Self::short(url), if fetch { "?fetch=true" } else { "" }) } } diff --git a/web/src/page.rs b/web/src/page.rs index dc01fcf..f3dff90 100644 --- a/web/src/page.rs +++ b/web/src/page.rs @@ -41,7 +41,7 @@ pub fn UserPage() -> impl IntoView { match CACHE.get(&Uri::full("users", &id)) { Some(x) => Some(x.clone()), None => { - let user : serde_json::Value = Http::fetch(&Uri::api("users", &id), auth).await.ok()?; + let user : serde_json::Value = Http::fetch(&Uri::api("users", &id, true), auth).await.ok()?; CACHE.put(Uri::full("users", &id), user.clone()); Some(user) }, @@ -116,7 +116,7 @@ pub fn UserPage() -> impl IntoView { } - + }.into_view() }, }} @@ -134,7 +134,7 @@ pub fn ObjectPage() -> impl IntoView { match CACHE.get(&Uri::full("objects", &oid)) { Some(x) => Some(x.clone()), None => { - let obj = Http::fetch::(&Uri::api("objects", &oid), auth).await.ok()?; + let obj = Http::fetch::(&Uri::api("objects", &oid, true), auth).await.ok()?; CACHE.put(Uri::full("objects", &oid), obj.clone()); Some(obj) } diff --git a/web/src/timeline.rs b/web/src/timeline.rs index 2f72703..badc59b 100644 --- a/web/src/timeline.rs +++ b/web/src/timeline.rs @@ -126,7 +126,7 @@ async fn process_activities( } async fn fetch_and_update(kind: &'static str, id: String, auth: Signal>) { - match Http::fetch(&Uri::api(kind, &id), auth).await { + match Http::fetch(&Uri::api(kind, &id, false), auth).await { Ok(data) => CACHE.put(id, data), Err(e) => console_warn(&format!("could not fetch '{id}': {e}")), }