fix(web): context and replies root id

This commit is contained in:
əlemi 2024-11-11 00:40:39 +01:00
parent 63e1e1f440
commit ae85351b11
Signed by: alemi
GPG key ID: A4895B84D311642C
2 changed files with 10 additions and 6 deletions

View file

@ -7,16 +7,18 @@ use crate::prelude::*;
pub fn ObjectContext() -> impl IntoView {
let feeds = use_context::<Feeds>().expect("missing feeds context");
let params = use_params::<IdParam>();
let id = Signal::derive(move || {
params.get().ok().and_then(|x| x.id).unwrap_or_default()
});
create_effect(move |_| {
let id = params.get().ok().and_then(|x| x.id).unwrap_or_default();
let tl_url = format!("{}/context/page", Uri::api(U::Object, &id, false));
let tl_url = format!("{}/context/page", Uri::api(U::Object, &id.get(), false));
if !feeds.context.next.get_untracked().starts_with(&tl_url) {
feeds.context.reset(Some(tl_url));
}
});
view! {
<div class="mr-1-r ml-1-r">
<Thread tl=feeds.context root=params.get().unwrap().id.unwrap() />
<Thread tl=feeds.context root=Uri::full(U::Object, &id.get()) />
</div>
}
}

View file

@ -7,16 +7,18 @@ use crate::prelude::*;
pub fn ObjectReplies() -> impl IntoView {
let feeds = use_context::<Feeds>().expect("missing feeds context");
let params = use_params::<IdParam>();
let id = Signal::derive(move ||
params.get().ok().and_then(|x| x.id).unwrap_or_default()
);
create_effect(move |_| {
let id = params.get().ok().and_then(|x| x.id).unwrap_or_default();
let tl_url = format!("{}/replies/page", Uri::api(U::Object, &id, false));
let tl_url = format!("{}/replies/page", Uri::api(U::Object, &id.get(), false));
if !feeds.replies.next.get_untracked().starts_with(&tl_url) {
feeds.replies.reset(Some(tl_url));
}
});
view! {
<div class="mr-1-r ml-1-r">
<Thread tl=feeds.replies root=params.get().unwrap().id.unwrap() />
<Thread tl=feeds.replies root=Uri::full(U::Object, &id.get()) />
</div>
}
}