From ee6120190dddd0cc998a0622829d7bd50d11e182 Mon Sep 17 00:00:00 2001 From: alemi Date: Mon, 29 Apr 2024 21:02:13 +0200 Subject: [PATCH] feat(web): show replies/likes/shares counters soon to be buttons! --- web/src/components/object.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/web/src/components/object.rs b/web/src/components/object.rs index b21b1d2e..62a02361 100644 --- a/web/src/components/object.rs +++ b/web/src/components/object.rs @@ -1,7 +1,7 @@ use leptos::*; use crate::{prelude::*, URL_SENSITIVE}; -use apb::{target::Addressed, Base, Object}; +use apb::{target::Addressed, Base, Collection, Object}; #[component] pub fn Attachment( @@ -86,6 +86,18 @@ pub fn Object(object: serde_json::Value) -> impl IntoView { let attachments = object.attachment() .map(|x| view! { }) .collect_view(); + let comments = object.replies().get() + .map(|x| x.total_items().unwrap_or(0)) + .filter(|x| *x > 0) + .map(|x| view! { {x} }); + let likes = object.audience().get() + .map(|x| x.total_items().unwrap_or(0)) + .filter(|x| *x > 0) + .map(|x| view! { {x} }); + let shares = object.generator().get() + .map(|x| x.total_items().unwrap_or(0)) + .filter(|x| *x > 0) + .map(|x| view! { {x} }); let attachments_padding = if object.attachment().is_empty() { None } else { @@ -114,6 +126,11 @@ pub fn Object(object: serde_json::Value) -> impl IntoView { {attachments} +
+ {comments}" 📨" + {likes}" ⭐" + {shares}" 🚀" +
} }