fix(web): items are responsive to filters changes
is this excessive? having everything in a closure...
This commit is contained in:
parent
da1f269850
commit
86a45d6082
1 changed files with 36 additions and 34 deletions
|
@ -45,39 +45,41 @@ pub fn Item(
|
|||
let config = use_context::<Signal<crate::Config>>().expect("missing config context");
|
||||
let id = item.id().unwrap_or_default().to_string();
|
||||
let sep = if sep { Some(view! { <hr /> }) } else { None };
|
||||
if !replies && !config.get().filters.visible(&item) {
|
||||
return None;
|
||||
}
|
||||
match item.object_type().unwrap_or(apb::ObjectType::Object) {
|
||||
// special case for placeholder activities
|
||||
apb::ObjectType::Note | apb::ObjectType::Document(_) =>
|
||||
Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()),
|
||||
// everything else
|
||||
apb::ObjectType::Activity(t) => {
|
||||
let object_id = item.object().id().str().unwrap_or_default();
|
||||
let object = match t {
|
||||
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
||||
CACHE.get(&object_id).map(|obj| {
|
||||
view! { <Object object=obj /> }
|
||||
}.into_view()),
|
||||
apb::ActivityType::Follow =>
|
||||
CACHE.get(&object_id).map(|obj| {
|
||||
view! {
|
||||
<div class="ml-1">
|
||||
<ActorBanner object=obj />
|
||||
<FollowRequestButtons activity_id=id.clone() actor_id=object_id />
|
||||
</div>
|
||||
}
|
||||
}.into_view()),
|
||||
_ => None,
|
||||
};
|
||||
Some(view! {
|
||||
<ActivityLine activity=item.clone() />
|
||||
{object}
|
||||
{sep.clone()}
|
||||
}.into_view())
|
||||
},
|
||||
// should never happen
|
||||
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()),
|
||||
move || {
|
||||
if !replies && !config.get().filters.visible(&item) {
|
||||
return None;
|
||||
}
|
||||
match item.object_type().unwrap_or(apb::ObjectType::Object) {
|
||||
// special case for placeholder activities
|
||||
apb::ObjectType::Note | apb::ObjectType::Document(_) =>
|
||||
Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()),
|
||||
// everything else
|
||||
apb::ObjectType::Activity(t) => {
|
||||
let object_id = item.object().id().str().unwrap_or_default();
|
||||
let object = match t {
|
||||
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
||||
CACHE.get(&object_id).map(|obj| {
|
||||
view! { <Object object=obj /> }
|
||||
}.into_view()),
|
||||
apb::ActivityType::Follow =>
|
||||
CACHE.get(&object_id).map(|obj| {
|
||||
view! {
|
||||
<div class="ml-1">
|
||||
<ActorBanner object=obj />
|
||||
<FollowRequestButtons activity_id=id.clone() actor_id=object_id />
|
||||
</div>
|
||||
}
|
||||
}.into_view()),
|
||||
_ => None,
|
||||
};
|
||||
Some(view! {
|
||||
<ActivityLine activity=item.clone() />
|
||||
{object}
|
||||
{sep.clone()}
|
||||
}.into_view())
|
||||
},
|
||||
// should never happen
|
||||
t => Some(view! { <p><code>type not implemented : {t.as_ref().to_string()}</code></p> }.into_view()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue