From 2bce5d480f8fbf283d400fe43f31633317d799df Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Wed, 9 Apr 2025 10:13:11 +0800 Subject: [PATCH] Handle more filter context for notifications --- src/components/notification.jsx | 4 +- src/components/status.jsx | 4 +- src/pages/filters.jsx | 2 +- src/pages/home.jsx | 65 +++++++++++++++++---------------- src/pages/mentions.jsx | 1 + src/pages/notifications.jsx | 5 ++- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/src/components/notification.jsx b/src/components/notification.jsx index c7f11a40..1ed17190 100644 --- a/src/components/notification.jsx +++ b/src/components/notification.jsx @@ -460,7 +460,6 @@ function Notification({ const expandAccounts = diffCount ? 'remote' : 'local'; // If there's a status and filter action is 'hide', then the notification is hidden - // TODO: Handle 'warn' action one day if (!!status?.filtered) { const isOwnPost = status?.account?.id === currentAccount; const filterInfo = isFiltered(status.filtered, 'notifications'); @@ -710,6 +709,7 @@ function Notification({ size="s" previewMode allowContextMenu + allowFilters /> @@ -749,6 +749,7 @@ function Notification({ size="s" readOnly allowContextMenu + allowFilters /> ) : ( )} diff --git a/src/components/status.jsx b/src/components/status.jsx index 10e1e621..e2bc86ae 100644 --- a/src/components/status.jsx +++ b/src/components/status.jsx @@ -3679,7 +3679,7 @@ function FilteredStatus({ return (
{ diff --git a/src/pages/filters.jsx b/src/pages/filters.jsx index ea8c9575..37fba580 100644 --- a/src/pages/filters.jsx +++ b/src/pages/filters.jsx @@ -18,7 +18,7 @@ import useInterval from '../utils/useInterval'; import useTitle from '../utils/useTitle'; const FILTER_CONTEXT = ['home', 'public', 'notifications', 'thread', 'account']; -const FILTER_CONTEXT_UNIMPLEMENTED = ['notifications', 'thread', 'account']; +const FILTER_CONTEXT_UNIMPLEMENTED = ['thread', 'account']; const FILTER_CONTEXT_LABELS = { home: msg`Home and lists`, notifications: msg`Notifications`, diff --git a/src/pages/home.jsx b/src/pages/home.jsx index debc9675..dba83dac 100644 --- a/src/pages/home.jsx +++ b/src/pages/home.jsx @@ -14,6 +14,7 @@ import Loader from '../components/loader'; import Notification from '../components/notification'; import { api } from '../utils/api'; import db from '../utils/db'; +import FilterContext from '../utils/filter-context'; import { massageNotifications2 } from '../utils/group-notifications'; import states, { saveStatus } from '../utils/states'; import { getCurrentAccountNS } from '../utils/store-utils'; @@ -185,39 +186,41 @@ function NotificationsMenu({ anchorRef, state, onClose }) { Notifications -
- {snapStates.notifications.length ? ( - <> - {snapStates.notifications - .slice(0, NOTIFICATIONS_DISPLAY_LIMIT) - .map((notification) => ( - - ))} - - ) : uiState === 'loading' ? ( -
- -
- ) : ( - uiState === 'error' && ( + +
+ {snapStates.notifications.length ? ( + <> + {snapStates.notifications + .slice(0, NOTIFICATIONS_DISPLAY_LIMIT) + .map((notification) => ( + + ))} + + ) : uiState === 'loading' ? (
-

- Unable to fetch notifications. -

-

- -

+
- ) - )} -
+ ) : ( + uiState === 'error' && ( +
+

+ Unable to fetch notifications. +

+

+ +

+
+ ) + )} +
+