{attachments_padding}
{attachments}
@@ -140,11 +140,11 @@ pub fn Object(object: crate::Object) -> impl IntoView {
};
let post = match object.object_type() {
// mastodon, pleroma, misskey
- Some(apb::ObjectType::Note) => view! {
+ Ok(apb::ObjectType::Note) => view! {
{post_inner}
}.into_view(),
// lemmy with Page, peertube with Video
- Some(apb::ObjectType::Document(t)) => view! {
+ Ok(apb::ObjectType::Document(t)) => view! {
{object.name().unwrap_or_default().to_string()}
@@ -155,7 +155,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
}.into_view(),
// wordpress, ... ?
- Some(apb::ObjectType::Article) => view! {
+ Ok(apb::ObjectType::Article) => view! {
{object.name().unwrap_or_default().to_string()}
@@ -163,12 +163,12 @@ pub fn Object(object: crate::Object) -> impl IntoView {
}.into_view(),
// everything else
- Some(t) => view! {
+ Ok(t) => view! {
{t.as_ref().to_string()}
{post_inner}
}.into_view(),
// object without type?
- None => view! { missing object type
}.into_view(),
+ Err(_) => view! { missing object type
}.into_view(),
};
view! {
@@ -180,7 +180,7 @@ pub fn Object(object: crate::Object) -> impl IntoView {
})}
-
+
"↗"
@@ -253,7 +253,7 @@ pub fn LikeButton(
if let Some(cached) = CACHE.get(&target) {
let mut new = (*cached).clone().set_liked_by_me(Some(true));
if let Some(likes) = new.likes().get() {
- if let Some(count) = likes.total_items() {
+ if let Ok(count) = likes.total_items() {
new = new.set_likes(apb::Node::object(likes.clone().set_total_items(Some(count + 1))));
}
}
diff --git a/web/src/components/post.rs b/web/src/components/post.rs
index 59e88c77..9470d3c1 100644
--- a/web/src/components/post.rs
+++ b/web/src/components/post.rs
@@ -13,7 +13,7 @@ impl ReplyControls {
pub fn reply(&self, oid: &str) {
if let Some(obj) = CACHE.get(oid) {
self.context.set(obj.context().id());
- self.reply_to.set(obj.id().map(|x| x.to_string()));
+ self.reply_to.set(obj.id().ok().map(|x| x.to_string()));
}
}
@@ -123,7 +123,7 @@ pub fn PostBox(advanced: WriteSignal) -> impl IntoView {
}
if let Some(r) = reply.reply_to.get() {
if let Some(au) = post_author(&r) {
- if let Some(uid) = au.id() {
+ if let Ok(uid) = au.id() {
to_vec.push(uid.to_string());
}
}
diff --git a/web/src/components/timeline.rs b/web/src/components/timeline.rs
index 791558c5..c7604129 100644
--- a/web/src/components/timeline.rs
+++ b/web/src/components/timeline.rs
@@ -85,13 +85,13 @@ pub fn TimelineRepliesRecursive(tl: Timeline, root: String) -> impl IntoView {
.into_iter()
.filter_map(|x| CACHE.get(&x))
.filter(|x| match x.object_type() {
- Some(apb::ObjectType::Activity(apb::ActivityType::Create)) => {
+ Ok(apb::ObjectType::Activity(apb::ActivityType::Create)) => {
let Some(oid) = x.object().id() else { return false; };
let Some(object) = CACHE.get(&oid) else { return false; };
let Some(reply) = object.in_reply_to().id() else { return false; };
reply == root
},
- Some(apb::ObjectType::Activity(_)) => x.object().id().map(|o| o == root).unwrap_or(false),
+ Ok(apb::ObjectType::Activity(_)) => x.object().id().map(|o| o == root).unwrap_or(false),
_ => x.in_reply_to().id().map(|r| r == root).unwrap_or(false),
})
.collect::>();
@@ -202,7 +202,7 @@ async fn process_activities(activities: Vec, auth: Auth) -> V
if let Some(attributed_to) = object.attributed_to().id() {
actors_seen.insert(attributed_to);
}
- if let Some(object_uri) = object.id() {
+ if let Ok(object_uri) = object.id() {
CACHE.put(object_uri.to_string(), Arc::new(object.clone()));
} else {
tracing::warn!("embedded object without id: {object:?}");
@@ -222,7 +222,7 @@ async fn process_activities(activities: Vec, auth: Auth) -> V
// save activity, removing embedded object
let object_id = activity.object().id();
- if let Some(activity_id) = activity.id() {
+ if let Ok(activity_id) = activity.id() {
out.push(activity_id.to_string());
CACHE.put(
activity_id.to_string(),
diff --git a/web/src/page/user.rs b/web/src/page/user.rs
index 12285118..ffdce3f5 100644
--- a/web/src/page/user.rs
+++ b/web/src/page/user.rs
@@ -82,7 +82,7 @@ pub fn UserPage(tl: Timeline) -> impl IntoView {
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 created = object.published().ok();
let following = object.following_count().unwrap_or(0);
let followers = object.followers_count().unwrap_or(0);
let statuses = object.statuses_count().unwrap_or(0);