fix(web): thread page uses obj context, not id
This commit is contained in:
parent
d8feeec26f
commit
677cab1871
1 changed files with 18 additions and 9 deletions
|
@ -15,15 +15,16 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView {
|
||||||
let object = create_local_resource(
|
let object = create_local_resource(
|
||||||
move || params.get().get("id").cloned().unwrap_or_default(),
|
move || params.get().get("id").cloned().unwrap_or_default(),
|
||||||
move |oid| async move {
|
move |oid| async move {
|
||||||
let tl_url = format!("{}/page", Uri::api(U::Context, &oid, false));
|
let obj = match CACHE.get(&Uri::full(U::Object, &oid)) {
|
||||||
if !tl.next.get().starts_with(&tl_url) {
|
Some(x) => x.clone(),
|
||||||
tl.reset(tl_url);
|
|
||||||
}
|
|
||||||
match CACHE.get(&Uri::full(U::Object, &oid)) {
|
|
||||||
Some(x) => Some(x.clone()),
|
|
||||||
None => {
|
None => {
|
||||||
let obj = Http::fetch::<serde_json::Value>(&Uri::api(U::Object, &oid, true), auth).await.ok()?;
|
let obj = match Http::fetch::<serde_json::Value>(&Uri::api(U::Object, &oid, true), auth).await {
|
||||||
let obj = Arc::new(obj);
|
Ok(obj) => Arc::new(obj),
|
||||||
|
Err(e) => {
|
||||||
|
tracing::error!("failed loading object from backend: {e}");
|
||||||
|
return None;
|
||||||
|
},
|
||||||
|
};
|
||||||
if let Ok(author) = obj.attributed_to().id() {
|
if let Ok(author) = obj.attributed_to().id() {
|
||||||
if let Ok(user) = Http::fetch::<serde_json::Value>(
|
if let Ok(user) = Http::fetch::<serde_json::Value>(
|
||||||
&Uri::api(U::Actor, author, true), auth
|
&Uri::api(U::Actor, author, true), auth
|
||||||
|
@ -32,10 +33,18 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CACHE.put(Uri::full(U::Object, &oid), obj.clone());
|
CACHE.put(Uri::full(U::Object, &oid), obj.clone());
|
||||||
|
obj
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Ok(ctx) = obj.context().id() {
|
||||||
|
let tl_url = format!("{}/page", ctx);
|
||||||
|
if !tl.next.get().starts_with(&tl_url) {
|
||||||
|
tl.reset(tl_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some(obj)
|
Some(obj)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
view! {
|
view! {
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in a new issue