fix(web): context should work in replies too

This commit is contained in:
əlemi 2024-11-20 23:05:09 +01:00
parent 5f998e9773
commit 284f1023a4
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

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