From de4f1aaabf5a70af57f2d87b657c1bba9d09daf2 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 4 Nov 2022 13:02:23 -0500 Subject: [PATCH] Notifications: exclude chat messages from "All" filter, improve exclude_types fallback --- app/soapbox/actions/notifications.ts | 6 ++++-- app/soapbox/utils/notification.ts | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/soapbox/actions/notifications.ts b/app/soapbox/actions/notifications.ts index 4edd76c22..db8fd688f 100644 --- a/app/soapbox/actions/notifications.ts +++ b/app/soapbox/actions/notifications.ts @@ -11,7 +11,7 @@ import { getFilters, regexFromFilters } from 'soapbox/selectors'; import { isLoggedIn } from 'soapbox/utils/auth'; import { getFeatures, parseVersion, PLEROMA } from 'soapbox/utils/features'; import { unescapeHTML } from 'soapbox/utils/html'; -import { NOTIFICATION_TYPES } from 'soapbox/utils/notification'; +import { EXCLUDE_TYPES, NOTIFICATION_TYPES } from 'soapbox/utils/notification'; import { joinPublicPath } from 'soapbox/utils/static'; import { fetchRelationships } from './accounts'; @@ -195,7 +195,9 @@ const expandNotifications = ({ maxId }: Record = {}, done: () => an if (activeFilter === 'all') { if (features.notificationsIncludeTypes) { - params.types = NOTIFICATION_TYPES; + params.types = NOTIFICATION_TYPES.filter(type => !EXCLUDE_TYPES.includes(type as any)); + } else { + params.exclude_types = EXCLUDE_TYPES; } } else { if (features.notificationsIncludeTypes) { diff --git a/app/soapbox/utils/notification.ts b/app/soapbox/utils/notification.ts index 907a97434..49c360b92 100644 --- a/app/soapbox/utils/notification.ts +++ b/app/soapbox/utils/notification.ts @@ -14,6 +14,12 @@ const NOTIFICATION_TYPES = [ 'update', ] as const; +/** Notification types to exclude from the "All" filter by default. */ +const EXCLUDE_TYPES = [ + 'pleroma:chat_mention', + 'chat', // TruthSocial +] as const; + type NotificationType = typeof NOTIFICATION_TYPES[number]; /** Ensure the Notification is a valid, known type. */ @@ -21,6 +27,7 @@ const validType = (type: string): type is NotificationType => NOTIFICATION_TYPES export { NOTIFICATION_TYPES, + EXCLUDE_TYPES, NotificationType, validType, };