//
{
dissolve::strip_html_tags(&summary)
.into_iter()
.map(|x| view! { {x} })
.collect_view()
}
}.into_view()
},
}
}}
}
}
#[component]
pub fn ObjectPage(tl: Timeline) -> impl IntoView {
let params = use_params_map();
let auth = use_context::().expect("missing auth context");
let mut uid = params.get().get("id")
.cloned()
.unwrap_or_default()
.replace("/web/objects/", "")
.replacen('+', "https://", 1)
.replace('@', "/");
if !uid.starts_with("http") {
uid = format!("{URL_BASE}/web/objects/{uid}");
}
let object = create_local_resource(move || params.get().get("id").cloned().unwrap_or_default(), move |oid| {
async move {
match CACHE.get(&Uri::full(FetchKind::Object, &oid)) {
Some(x) => Some(x.clone()),
None => {
let obj = Http::fetch::(&Uri::api(FetchKind::Object, &oid, true), auth).await.ok()?;
CACHE.put(Uri::full(FetchKind::Object, &oid), obj.clone());
Some(obj)
}
}
}
});
view! {
objects::view
{move || match object.get() {
None => view! { loading ... }.into_view(),
Some(None) => {
let uid = uid.clone();
view! { loading failed "↗"
}.into_view()
},
Some(Some(o)) => {
let object = o.clone();
let tl_url = format!("{}/page", Uri::api(FetchKind::Context, &o.context().id().unwrap_or_default(), false));
if !tl.next.get().starts_with(&tl_url) {
tl.reset(tl_url);
}
view!{
}.into_view()
},
}}
}
}
#[component]
pub fn TimelinePage(name: &'static str, tl: Timeline) -> impl IntoView {
let auth = use_context::().expect("missing auth context");
view! {
}
}
#[component]
pub fn DebugPage() -> impl IntoView {
let (object, set_object) = create_signal(serde_json::Value::String(
"use this view to fetch remote AP objects and inspect their content".into())
);
let cached_ref: NodeRef = create_node_ref();
let auth = use_context::().expect("missing auth context");
let (query, set_query) = create_signal("".to_string());
view! {
debug
{move || serde_json::to_string_pretty(&object.get()).unwrap_or("unserializable".to_string())}
}
}
|