From 227e9c625b3b736abdc3834e3a8ab2b8086bbe52 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 12 May 2024 00:12:07 +0200 Subject: [PATCH] feat(web): filter timelines, loop videos, open cws --- web/src/components/activity.rs | 67 +++++++++++++++++++++------------- web/src/components/object.rs | 12 +++--- web/src/components/timeline.rs | 3 +- 3 files changed, 49 insertions(+), 33 deletions(-) diff --git a/web/src/components/activity.rs b/web/src/components/activity.rs index 1994d4ad..e1298c22 100644 --- a/web/src/components/activity.rs +++ b/web/src/components/activity.rs @@ -33,36 +33,51 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView { } #[component] -pub fn Item(item: crate::Object) -> impl IntoView { +pub fn Item( + item: crate::Object, + #[prop(optional)] sep: bool, +) -> impl IntoView { + let config = use_context::>().expect("missing config context"); let id = item.id().unwrap_or_default().to_string(); + let sep = if sep { Some(view! {
}) } else { None }; match item.object_type() { // special case for placeholder activities - Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) => - view! { }.into_view(), + Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) => (move || { + if config.get().filters.orphans { + Some(view! { {sep.clone()} }) + } else { + None + } + }).into_view(), // everything else - Some(apb::ObjectType::Activity(t)) => { - let object_id = item.object().id().unwrap_or_default(); - let object = match t { - apb::ActivityType::Create | apb::ActivityType::Announce => - CACHE.get(&object_id).map(|obj| { - view! { } - }.into_view()), - apb::ActivityType::Follow => - CACHE.get(&object_id).map(|obj| { - view! { -
- - -
- } - }.into_view()), - _ => None, - }; - view! { - - {object} - }.into_view() - }, + Some(apb::ObjectType::Activity(t)) => (move || { + if config.get().filters.visible(apb::ObjectType::Activity(t)) { + let object_id = item.object().id().unwrap_or_default(); + let object = match t { + apb::ActivityType::Create | apb::ActivityType::Announce => + CACHE.get(&object_id).map(|obj| { + view! { } + }.into_view()), + apb::ActivityType::Follow => + CACHE.get(&object_id).map(|obj| { + view! { +
+ + +
+ } + }.into_view()), + _ => None, + }; + Some(view! { + + {object} + {sep.clone()} + }) + } else { + None + } + }).into_view(), // should never happen _ => view! {

type not implemented

}.into_view(), } diff --git a/web/src/components/object.rs b/web/src/components/object.rs index 02065ce9..da2a7b0b 100644 --- a/web/src/components/object.rs +++ b/web/src/components/object.rs @@ -11,6 +11,7 @@ pub fn Attachment( #[prop(optional)] sensitive: bool ) -> impl IntoView { + let config = use_context::>().expect("missing config context"); let (expand, set_expand) = create_signal(false); let href = object.url().id().unwrap_or_default(); let media_type = object.media_type() @@ -47,7 +48,7 @@ pub fn Attachment( on:click=move |_| set_expand.set(!expand.get()) title={object.name().unwrap_or_default().to_string()} > -