From 7efb5729bdc3a9212eecdbfacd1db9981ef96798 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 1 Nov 2022 13:16:25 -0500 Subject: [PATCH] Display only know notification types --- app/soapbox/actions/notifications.ts | 17 ++++++++--------- .../notifications/components/notification.tsx | 2 +- app/soapbox/reducers/notifications.js | Bin 7261 -> 7432 bytes 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/app/soapbox/actions/notifications.ts b/app/soapbox/actions/notifications.ts index 79994bde51..4edd76c225 100644 --- a/app/soapbox/actions/notifications.ts +++ b/app/soapbox/actions/notifications.ts @@ -1,5 +1,4 @@ import { - List as ImmutableList, Map as ImmutableMap, } from 'immutable'; import IntlMessageFormat from 'intl-messageformat'; @@ -12,6 +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 { joinPublicPath } from 'soapbox/utils/static'; import { fetchRelationships } from './accounts'; @@ -168,11 +168,8 @@ const dequeueNotifications = () => dispatch(markReadNotifications()); }; -// const excludeTypesFromSettings = (getState: () => RootState) => (getSettings(getState()).getIn(['notifications', 'shows']) as ImmutableMap).filter(enabled => !enabled).keySeq().toJS(); - const excludeTypesFromFilter = (filter: string) => { - const allTypes = ImmutableList(['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'status', 'poll', 'move', 'pleroma:emoji_reaction']); - return allTypes.filterNot(item => item === filter).toJS(); + return NOTIFICATION_TYPES.filter(item => item !== filter); }; const noOp = () => new Promise(f => f(undefined)); @@ -182,6 +179,7 @@ const expandNotifications = ({ maxId }: Record = {}, done: () => an if (!isLoggedIn(getState)) return dispatch(noOp); const state = getState(); + const features = getFeatures(state.instance); const activeFilter = getSettings(state).getIn(['notifications', 'quickFilter', 'active']) as string; const notifications = state.notifications; const isLoadingMore = !!maxId; @@ -195,10 +193,11 @@ const expandNotifications = ({ maxId }: Record = {}, done: () => an max_id: maxId, }; - if (activeFilter !== 'all') { - const instance = state.instance; - const features = getFeatures(instance); - + if (activeFilter === 'all') { + if (features.notificationsIncludeTypes) { + params.types = NOTIFICATION_TYPES; + } + } else { if (features.notificationsIncludeTypes) { params.types = [activeFilter]; } else { diff --git a/app/soapbox/features/notifications/components/notification.tsx b/app/soapbox/features/notifications/components/notification.tsx index e1fa87c5a0..1871b3a892 100644 --- a/app/soapbox/features/notifications/components/notification.tsx +++ b/app/soapbox/features/notifications/components/notification.tsx @@ -268,7 +268,7 @@ const Notification: React.FC = (props) => { }; const renderContent = () => { - switch (type) { + switch (type as NotificationType) { case 'follow': case 'user_approved': return account && typeof account === 'object' ? ( diff --git a/app/soapbox/reducers/notifications.js b/app/soapbox/reducers/notifications.js index d7697d4ddf3414da24412f2fe876db945d78db48..4d5dd9921461585ca5c513388b4edf4d41b5ac1c 100644 GIT binary patch delta 137 zcmca>(P1@Vi+W~mL4Hw*LbXC!VoqjCNM%8)LajntQGTw1dU1YYK~jE&erZW&&c?;F z*?e8|ic5=96-qKv74q^+GSf1X6H7Al^As|R6%rM)^YY8{6iR>wa47&mW}1SABHT<3 UWc7L=MVgb-Ig~eBvnz=L01rAb;Q#;t delta 15 XcmeCMx@$3E%f>fdY@1)Q%Zma4KT-!E