forked from alemi/upub
feat(web): allow filtering replies
This commit is contained in:
parent
a6227a6679
commit
892637db04
3 changed files with 32 additions and 22 deletions
|
@ -43,7 +43,9 @@ pub fn Item(
|
||||||
match item.object_type() {
|
match item.object_type() {
|
||||||
// special case for placeholder activities
|
// special case for placeholder activities
|
||||||
Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) => (move || {
|
Some(apb::ObjectType::Note) | Some(apb::ObjectType::Document(_)) => (move || {
|
||||||
if config.get().filters.orphans {
|
if !config.get().filters.replies && item.in_reply_to().id().is_some() {
|
||||||
|
None
|
||||||
|
} else if config.get().filters.orphans {
|
||||||
Some(view! { <Object object=item.clone() />{sep.clone()} })
|
Some(view! { <Object object=item.clone() />{sep.clone()} })
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
|
@ -53,6 +55,9 @@ pub fn Item(
|
||||||
Some(apb::ObjectType::Activity(t)) => (move || {
|
Some(apb::ObjectType::Activity(t)) => (move || {
|
||||||
if config.get().filters.visible(apb::ObjectType::Activity(t)) {
|
if config.get().filters.visible(apb::ObjectType::Activity(t)) {
|
||||||
let object_id = item.object().id().unwrap_or_default();
|
let object_id = item.object().id().unwrap_or_default();
|
||||||
|
if !config.get().filters.replies && CACHE.get(&object_id).map(|x| x.in_reply_to().id().is_some()).unwrap_or(false) {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
let object = match t {
|
let object = match t {
|
||||||
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
apb::ActivityType::Create | apb::ActivityType::Announce =>
|
||||||
CACHE.get(&object_id).map(|obj| {
|
CACHE.get(&object_id).map(|obj| {
|
||||||
|
@ -74,6 +79,7 @@ pub fn Item(
|
||||||
{object}
|
{object}
|
||||||
{sep.clone()}
|
{sep.clone()}
|
||||||
})
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ pub struct Config {
|
||||||
#[serde_inline_default::serde_inline_default]
|
#[serde_inline_default::serde_inline_default]
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, serde_default::DefaultFromSerde)]
|
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, serde_default::DefaultFromSerde)]
|
||||||
pub struct FiltersConfig {
|
pub struct FiltersConfig {
|
||||||
|
#[serde_inline_default(false)]
|
||||||
|
pub replies: bool,
|
||||||
|
|
||||||
#[serde_inline_default(false)]
|
#[serde_inline_default(false)]
|
||||||
pub likes: bool,
|
pub likes: bool,
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ pub fn ConfigPage(setter: WriteSignal<crate::Config>) -> impl IntoView {
|
||||||
<hr />
|
<hr />
|
||||||
<p><code title="unchecked elements won't show in timelines">filters</code></p>
|
<p><code title="unchecked elements won't show in timelines">filters</code></p>
|
||||||
<ul>
|
<ul>
|
||||||
|
<li><span title="replies to other posts"><input type="checkbox" prop:checked=get_cfg!(filter replies) on:input=set_cfg!(filter replies) />" replies"</span></li>
|
||||||
<li><span title="like activities"><input type="checkbox" prop:checked=get_cfg!(filter likes) on:input=set_cfg!(filter likes) />" likes"</span></li>
|
<li><span title="like activities"><input type="checkbox" prop:checked=get_cfg!(filter likes) on:input=set_cfg!(filter likes) />" likes"</span></li>
|
||||||
<li><span title="create activities with object"><input type="checkbox" prop:checked=get_cfg!(filter creates) on:input=set_cfg!(filter creates)/>" creates"</span></li>
|
<li><span title="create activities with object"><input type="checkbox" prop:checked=get_cfg!(filter creates) on:input=set_cfg!(filter creates)/>" creates"</span></li>
|
||||||
<li><span title="announce activities with object"><input type="checkbox" prop:checked=get_cfg!(filter announces) on:input=set_cfg!(filter announces) />" announces"</span></li>
|
<li><span title="announce activities with object"><input type="checkbox" prop:checked=get_cfg!(filter announces) on:input=set_cfg!(filter announces) />" announces"</span></li>
|
||||||
|
|
Loading…
Reference in a new issue