From 3808d09976d39180cb5570fb76eadff9274e77e2 Mon Sep 17 00:00:00 2001
From: alemi
Date: Mon, 15 Apr 2024 03:03:01 +0200
Subject: [PATCH] feat: error boundary for fetching
---
web/src/lib.rs | 150 +++++++++++++++++++++++++++----------------------
1 file changed, 82 insertions(+), 68 deletions(-)
diff --git a/web/src/lib.rs b/web/src/lib.rs
index 12a2c93a..4e3d3e93 100644
--- a/web/src/lib.rs
+++ b/web/src/lib.rs
@@ -180,6 +180,10 @@ pub fn Activity(activity: serde_json::Value) -> impl IntoView {
}
}
+#[derive(Debug, thiserror::Error)]
+#[error("{0}")]
+struct OmgReqwestErrorIsNotClonable(String);
+
#[component]
pub fn Timeline(
token: Signal
} >
+ {move || items.with(|x| match x {
+ None => Ok(view! { loading...
}.into_view()),
+ Some(data) => match data {
+ Err(e) => Err(OmgReqwestErrorIsNotClonable(e.to_string())),
+ Ok(values) => Ok(
+ values
+ .iter()
+ .map(|object| {
+ let actor = object.actor().extract().unwrap_or_else(||
+ serde_json::Value::String(object.actor().id().unwrap_or_default())
+ );
+ view! {
+
+
+ }
+ })
+ .collect::>()
+ .into_view()
+ ),
+ }
+ })}
+
}
}
+
+async fn fetch_activities_with_users(
+ feed_url: &str,
+ token: Signal