1
0
Fork 0
forked from alemi/upub

fix(web): refresh user and thread tl on url change

This commit is contained in:
əlemi 2024-05-30 22:58:31 +02:00
parent 8251e3f550
commit 17c1765295
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 12 additions and 11 deletions

View file

@ -12,8 +12,13 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView {
let auth = use_context::<Auth>().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! {
<div>
<Breadcrumb back=true >
@ -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!{
<Object object=object />
<div class="ml-1 mr-1 mt-2">

View file

@ -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();