forked from alemi/upub
feat(web): individual views will request fetches
This commit is contained in:
parent
96e3681bf7
commit
59ebee71a8
3 changed files with 6 additions and 6 deletions
|
@ -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 { "" })
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
|||
}</blockquote>
|
||||
</div>
|
||||
</div>
|
||||
<TimelineFeed tl=Timeline::new(format!("{}/outbox/page", Uri::api("users", &id.clone()))) />
|
||||
<TimelineFeed tl=Timeline::new(format!("{}/outbox/page", Uri::api("users", &id.clone(), false))) />
|
||||
}.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::<serde_json::Value>(&Uri::api("objects", &oid), auth).await.ok()?;
|
||||
let obj = Http::fetch::<serde_json::Value>(&Uri::api("objects", &oid, true), auth).await.ok()?;
|
||||
CACHE.put(Uri::full("objects", &oid), obj.clone());
|
||||
Some(obj)
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ async fn process_activities(
|
|||
}
|
||||
|
||||
async fn fetch_and_update(kind: &'static str, id: String, auth: Signal<Option<String>>) {
|
||||
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}")),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue