From 17c1765295463c7177e9591b03921e7edc1015b7 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 30 May 2024 22:58:31 +0200 Subject: [PATCH] fix(web): refresh user and thread tl on url change --- web/src/page/object.rs | 15 ++++++++------- web/src/page/user.rs | 8 ++++---- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/web/src/page/object.rs b/web/src/page/object.rs index 01e72473..ca4d7cd7 100644 --- a/web/src/page/object.rs +++ b/web/src/page/object.rs @@ -12,8 +12,13 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView { let auth = use_context::().expect("missing auth context"); let id = params.get().get("id").cloned().unwrap_or_default(); let uid = uriproxy::uri(URL_BASE, uriproxy::UriClass::Object, &id); - let object = create_local_resource(move || params.get().get("id").cloned().unwrap_or_default(), move |oid| { - async move { + let object = create_local_resource( + move || params.get().get("id").cloned().unwrap_or_default(), + move |oid| async move { + let tl_url = format!("{}/page", Uri::api(U::Context, &oid, false)); + if !tl.next.get().starts_with(&tl_url) { + tl.reset(tl_url); + } match CACHE.get(&Uri::full(U::Object, &oid)) { Some(x) => Some(x.clone()), None => { @@ -31,7 +36,7 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView { } } } - }); + ); view! {
@@ -55,10 +60,6 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView { }, Some(Some(o)) => { let object = o.clone(); - let tl_url = format!("{}/page", Uri::api(U::Context, &o.context().id().unwrap_or_default(), false)); - if !tl.next.get().starts_with(&tl_url) { - tl.reset(tl_url); - } view!{
diff --git a/web/src/page/user.rs b/web/src/page/user.rs index 6bafae1a..12285118 100644 --- a/web/src/page/user.rs +++ b/web/src/page/user.rs @@ -32,6 +32,10 @@ pub fn UserPage(tl: Timeline) -> impl IntoView { move || params.get().get("id").cloned().unwrap_or_default(), move |id| { async move { + let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id, false)); + if !tl.next.get().starts_with(&tl_url) { + tl.reset(tl_url); + } match CACHE.get(&Uri::full(U::Actor, &id)) { Some(x) => Some(x.clone()), None => { @@ -82,10 +86,6 @@ pub fn UserPage(tl: Timeline) -> impl IntoView { let following = object.following_count().unwrap_or(0); let followers = object.followers_count().unwrap_or(0); let statuses = object.statuses_count().unwrap_or(0); - let tl_url = format!("{}/outbox/page", Uri::api(U::Actor, &id.clone(), false)); - if !tl.next.get().starts_with(&tl_url) { - tl.reset(tl_url); - } let following_me = object.following_me().unwrap_or(false); let followed_by_me = object.followed_by_me().unwrap_or(false); let _uid = uid.clone();