forked from alemi/upub
feat(web): error pages have direct link to debug
This commit is contained in:
parent
5a8887c690
commit
870e46ba31
1 changed files with 101 additions and 75 deletions
|
@ -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::<Auth>().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,9 +61,13 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
|
|||
<div>
|
||||
<Breadcrumb back=true >users::view</Breadcrumb>
|
||||
<div>
|
||||
{move || match actor.get() {
|
||||
None => view! { <p>loading...</p> }.into_view(),
|
||||
Some(None) => view! { <p><code>error loading</code></p> }.into_view(),
|
||||
{move || {
|
||||
let uid = uid.clone();
|
||||
match actor.get() {
|
||||
None => view! { <p class="center">loading...</p> }.into_view(),
|
||||
Some(None) => {
|
||||
view! { <p class="center"><code>loading failed</code><sup><small><a class="clean" href={uid} target="_blank">"↗"</a></small></sup></p> }.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();
|
||||
|
@ -124,6 +137,7 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
|
|||
<TimelineFeed tl=tl />
|
||||
}.into_view()
|
||||
},
|
||||
}
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
@ -134,6 +148,15 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
|
|||
pub fn ObjectPage(tl: Timeline) -> impl IntoView {
|
||||
let params = use_params_map();
|
||||
let auth = use_context::<Auth>().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)) {
|
||||
|
@ -151,8 +174,11 @@ pub fn ObjectPage(tl: Timeline) -> impl IntoView {
|
|||
<Breadcrumb back=true >objects::view</Breadcrumb>
|
||||
<div class="ma-2" >
|
||||
{move || match object.get() {
|
||||
None => view! { <p> loading ... </p> }.into_view(),
|
||||
Some(None) => view! { <p><code>loading failed</code></p> }.into_view(),
|
||||
None => view! { <p class="center"> loading ... </p> }.into_view(),
|
||||
Some(None) => {
|
||||
let uid = uid.clone();
|
||||
view! { <p class="center"><code>loading failed</code><sup><small><a class="clean" href={uid} target="_blank">"↗"</a></small></sup></p> }.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));
|
||||
|
|
Loading…
Reference in a new issue