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(
item: crate::Object,
#[prop(optional)] sep: bool,
#[prop(optional)] replies: bool,
#[prop(optional)] slim: bool,
#[prop(optional)] always: bool,
) -> impl IntoView {
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 };
move || {
if !replies && !config.get().filters.visible(&item) {
if !always && !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() reply=replies />{sep.clone()} }.into_view()),
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::OBJECTS.get(&object_id).map(|obj| {
view! { <Object object=obj reply=replies /> }
view! { <Object object=obj /> }
}.into_view()),
apb::ActivityType::Follow =>
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="global" view=move || view! { <Feed tl=feeds.global /> } />
<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="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};
#[component]
pub fn Object(
object: crate::Object,
#[prop(optional)] reply: bool,
) -> impl IntoView {
pub fn Object(object: crate::Object) -> impl IntoView {
let oid = object.id().unwrap_or_default().to_string();
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());

View file

@ -4,7 +4,11 @@ use crate::prelude::*;
use super::Timeline;
#[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");
if let Some(auto_scroll) = use_context::<Signal<bool>>() {
let _ = leptos::watch(
@ -22,7 +26,7 @@ pub fn Feed(tl: Timeline) -> impl IntoView {
>
{match cache::OBJECTS.get(&id) {
Some(i) => view! {
<Item item=i sep=true />
<Item item=i sep=true always=ignore_filters />
}.into_view(),
None => view! {
<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)|
view! {
<div class="context depth-r">
<Item item=obj replies=true slim=true />
<Item item=obj always=true slim=true />
<div class="depth-r">
<FeedRecursive tl=tl root=id />
</div>