From 870e46ba31e4ccda0ee1efa151b75d36309ea442 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 22 Apr 2024 02:48:33 +0200 Subject: [PATCH] feat(web): error pages have direct link to debug --- web/src/page.rs | 176 +++++++++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 75 deletions(-) diff --git a/web/src/page.rs b/web/src/page.rs index b7599704..503bb8b9 100644 --- a/web/src/page.rs +++ b/web/src/page.rs @@ -34,9 +34,18 @@ pub fn ConfigPage() -> impl IntoView { pub fn UserPage(tl: Timeline) -> impl IntoView { let params = use_params_map(); let auth = use_context::().expect("missing auth context"); - let id = params.get().get("id").cloned().unwrap_or_default(); - let _id = id.clone(); // wtf triple clone??? TODO!! - let actor = create_local_resource(move || _id.clone(), move |id| { + let id = params.get() + .get("id") + .cloned() + .unwrap_or_default(); + let mut uid = id + .replace("/web/objects/", "") + .replacen('+', "https://", 1) + .replace('@', "/"); + if !uid.starts_with("http") { + uid = format!("{URL_BASE}/web/objects/{uid}"); + } + let actor = create_local_resource(move || params.get().get("id").cloned().unwrap_or_default(), move |id| { async move { match CACHE.get(&Uri::full(FetchKind::User, &id)) { Some(x) => Some(x.clone()), @@ -52,78 +61,83 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
users::view
- {move || match actor.get() { - None => view! {

loading...

}.into_view(), - Some(None) => view! {

error loading

}.into_view(), - Some(Some(object)) => { - let uid = object.id().unwrap_or_default().to_string(); - let avatar_url = object.icon().get().map(|x| x.url().id().unwrap_or_default()).unwrap_or_default(); - let background_url = object.image().get().map(|x| x.url().id().unwrap_or_default()).unwrap_or_default(); - let display_name = object.name().unwrap_or_default().to_string(); - let username = object.preferred_username().unwrap_or_default().to_string(); - let summary = object.summary().unwrap_or_default().to_string(); - let domain = object.id().unwrap_or_default().replace("https://", "").split('/').next().unwrap_or_default().to_string(); - let actor_type = object.actor_type().unwrap_or(apb::ActorType::Person); - let actor_type_tag = if actor_type == apb::ActorType::Person { None } else { - Some(view! { "["{actor_type.as_ref().to_lowercase()}"]" } ) - }; - let created = object.published(); - let following = object.following().get().map(|x| x.total_items().unwrap_or(0)).unwrap_or(0); - let followers = object.followers().get().map(|x| x.total_items().unwrap_or(0)).unwrap_or(0); - let statuses = object.outbox().get().map(|x| x.total_items().unwrap_or(0)).unwrap_or(0); - let tl_url = format!("{}/outbox/page", Uri::api(FetchKind::User, &id.clone(), false)); - if !tl.next.get().starts_with(&tl_url) { - tl.reset(tl_url); - } - view! { -
-