1
0
Fork 0
forked from alemi/upub

fix(web): items are responsive to filters changes

is this excessive? having everything in a closure...
This commit is contained in:
əlemi 2024-06-06 21:46:28 +02:00
parent da1f269850
commit 86a45d6082
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -45,39 +45,41 @@ pub fn Item(
let config = use_context::<Signal<crate::Config>>().expect("missing config context"); let config = use_context::<Signal<crate::Config>>().expect("missing config context");
let id = item.id().unwrap_or_default().to_string(); let id = item.id().unwrap_or_default().to_string();
let sep = if sep { Some(view! { <hr /> }) } else { None }; let sep = if sep { Some(view! { <hr /> }) } else { None };
if !replies && !config.get().filters.visible(&item) { move || {
return None; if !replies && !config.get().filters.visible(&item) {
} return None;
match item.object_type().unwrap_or(apb::ObjectType::Object) { }
// special case for placeholder activities match item.object_type().unwrap_or(apb::ObjectType::Object) {
apb::ObjectType::Note | apb::ObjectType::Document(_) => // special case for placeholder activities
Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()), apb::ObjectType::Note | apb::ObjectType::Document(_) =>
// everything else Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()),
apb::ObjectType::Activity(t) => { // everything else
let object_id = item.object().id().str().unwrap_or_default(); apb::ObjectType::Activity(t) => {
let object = match t { let object_id = item.object().id().str().unwrap_or_default();
apb::ActivityType::Create | apb::ActivityType::Announce => let object = match t {
CACHE.get(&object_id).map(|obj| { apb::ActivityType::Create | apb::ActivityType::Announce =>
view! { <Object object=obj /> } CACHE.get(&object_id).map(|obj| {
}.into_view()), view! { <Object object=obj /> }
apb::ActivityType::Follow => }.into_view()),
CACHE.get(&object_id).map(|obj| { apb::ActivityType::Follow =>
view! { CACHE.get(&object_id).map(|obj| {
<div class="ml-1"> view! {
<ActorBanner object=obj /> <div class="ml-1">
<FollowRequestButtons activity_id=id.clone() actor_id=object_id /> <ActorBanner object=obj />
</div> <FollowRequestButtons activity_id=id.clone() actor_id=object_id />
} </div>
}.into_view()), }
_ => None, }.into_view()),
}; _ => None,
Some(view! { };
<ActivityLine activity=item.clone() /> Some(view! {
{object} <ActivityLine activity=item.clone() />
{sep.clone()} {object}
}.into_view()) {sep.clone()}
}, }.into_view())
// should never happen },
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()), // should never happen
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()),
}
} }
} }