fix(web): notifications ignore filters

This commit is contained in:
əlemi 2024-07-23 14:50:53 +02:00
parent 22e2fad343
commit 93f61ea0de
Signed by: alemi
GPG key ID: A4895B84D311642C
5 changed files with 13 additions and 12 deletions

View file

@ -42,27 +42,27 @@ pub fn ActivityLine(activity: crate::Object) -> impl IntoView {
pub fn Item( pub fn Item(
item: crate::Object, item: crate::Object,
#[prop(optional)] sep: bool, #[prop(optional)] sep: bool,
#[prop(optional)] replies: bool,
#[prop(optional)] slim: bool, #[prop(optional)] slim: bool,
#[prop(optional)] always: bool,
) -> impl IntoView { ) -> impl IntoView {
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 };
move || { move || {
if !replies && !config.get().filters.visible(&item) { if !always && !config.get().filters.visible(&item) {
return None; return None;
} }
match item.object_type().unwrap_or(apb::ObjectType::Object) { match item.object_type().unwrap_or(apb::ObjectType::Object) {
// special case for placeholder activities // special case for placeholder activities
apb::ObjectType::Note | apb::ObjectType::Document(_) => apb::ObjectType::Note | apb::ObjectType::Document(_) =>
Some(view! { <Object object=item.clone() reply=replies />{sep.clone()} }.into_view()), Some(view! { <Object object=item.clone() />{sep.clone()} }.into_view()),
// everything else // everything else
apb::ObjectType::Activity(t) => { apb::ObjectType::Activity(t) => {
let object_id = item.object().id().str().unwrap_or_default(); let object_id = item.object().id().str().unwrap_or_default();
let object = match t { let object = match t {
apb::ActivityType::Create | apb::ActivityType::Announce => apb::ActivityType::Create | apb::ActivityType::Announce =>
cache::OBJECTS.get(&object_id).map(|obj| { cache::OBJECTS.get(&object_id).map(|obj| {
view! { <Object object=obj reply=replies /> } view! { <Object object=obj /> }
}.into_view()), }.into_view()),
apb::ActivityType::Follow => apb::ActivityType::Follow =>
cache::OBJECTS.get(&object_id).map(|obj| { cache::OBJECTS.get(&object_id).map(|obj| {

View file

@ -134,7 +134,7 @@ pub fn App() -> impl IntoView {
<Route path="home" view=move || view! { <Feed tl=feeds.home /> } /> <Route path="home" view=move || view! { <Feed tl=feeds.home /> } />
<Route path="global" view=move || view! { <Feed tl=feeds.global /> } /> <Route path="global" view=move || view! { <Feed tl=feeds.global /> } />
<Route path="local" view=move || view! { <Feed tl=feeds.server /> } /> <Route path="local" view=move || view! { <Feed tl=feeds.server /> } />
<Route path="notifications" view=move || view! { <Feed tl=feeds.notifications /> } /> <Route path="notifications" view=move || view! { <Feed tl=feeds.notifications ignore_filters=true /> } />
<Route path="about" view=AboutPage /> <Route path="about" view=AboutPage />
<Route path="config" view=move || view! { <ConfigPage setter=set_config /> } /> <Route path="config" view=move || view! { <ConfigPage setter=set_config /> } />

View file

@ -6,10 +6,7 @@ use crate::prelude::*;
use apb::{field::OptionalString, target::Addressed, ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut}; use apb::{field::OptionalString, target::Addressed, ActivityMut, Base, Collection, CollectionMut, Object, ObjectMut};
#[component] #[component]
pub fn Object( pub fn Object(object: crate::Object) -> impl IntoView {
object: crate::Object,
#[prop(optional)] reply: bool,
) -> impl IntoView {
let oid = object.id().unwrap_or_default().to_string(); let oid = object.id().unwrap_or_default().to_string();
let author_id = object.attributed_to().id().str().unwrap_or_default(); let author_id = object.attributed_to().id().str().unwrap_or_default();
let author = cache::OBJECTS.get_or(&author_id, serde_json::Value::String(author_id.clone()).into()); let author = cache::OBJECTS.get_or(&author_id, serde_json::Value::String(author_id.clone()).into());

View file

@ -4,7 +4,11 @@ use crate::prelude::*;
use super::Timeline; use super::Timeline;
#[component] #[component]
pub fn Feed(tl: Timeline) -> impl IntoView { pub fn Feed(
tl: Timeline,
#[prop(optional)]
ignore_filters: bool,
) -> impl IntoView {
let auth = use_context::<Auth>().expect("missing auth context"); let auth = use_context::<Auth>().expect("missing auth context");
if let Some(auto_scroll) = use_context::<Signal<bool>>() { if let Some(auto_scroll) = use_context::<Signal<bool>>() {
let _ = leptos::watch( let _ = leptos::watch(
@ -22,7 +26,7 @@ pub fn Feed(tl: Timeline) -> impl IntoView {
> >
{match cache::OBJECTS.get(&id) { {match cache::OBJECTS.get(&id) {
Some(i) => view! { Some(i) => view! {
<Item item=i sep=true /> <Item item=i sep=true always=ignore_filters />
}.into_view(), }.into_view(),
None => view! { None => view! {
<p><code>{id}</code>" "[<a href={uri}>go</a>]</p> <p><code>{id}</code>" "[<a href={uri}>go</a>]</p>

View file

@ -64,7 +64,7 @@ fn FeedRecursive(tl: Timeline, root: String) -> impl IntoView {
children=move |(id, obj)| children=move |(id, obj)|
view! { view! {
<div class="context depth-r"> <div class="context depth-r">
<Item item=obj replies=true slim=true /> <Item item=obj always=true slim=true />
<div class="depth-r"> <div class="depth-r">
<FeedRecursive tl=tl root=id /> <FeedRecursive tl=tl root=id />
</div> </div>