11import { type FC , useMemo , useRef } from 'react' ;
22
33import { useAppContext } from '../hooks/useAppContext' ;
4+ import { useFiltersStore } from '../stores' ;
45
56import { AllRead } from '../components/AllRead' ;
67import { Contents } from '../components/layout/Contents' ;
@@ -13,6 +14,7 @@ import { getAccountUUID } from '../utils/auth/utils';
1314export const NotificationsRoute : FC = ( ) => {
1415 const { notifications, status, globalError, settings, hasNotifications } =
1516 useAppContext ( ) ;
17+ const filteredAccounts = useFiltersStore ( ( s ) => s . accounts ) ;
1618
1719 // Store previous successful state
1820 const prevStateRef = useRef ( {
@@ -48,9 +50,19 @@ export const NotificationsRoute: FC = () => {
4850 [ displayState . notifications ] ,
4951 ) ;
5052
53+ const visibleNotifications = useMemo (
54+ ( ) =>
55+ filteredAccounts . length === 0
56+ ? displayState . notifications
57+ : displayState . notifications . filter ( ( n ) =>
58+ filteredAccounts . includes ( getAccountUUID ( n . account ) ) ,
59+ ) ,
60+ [ displayState . notifications , filteredAccounts ] ,
61+ ) ;
62+
5163 const hasNoAccountErrors = useMemo (
52- ( ) => displayState . notifications . every ( ( account ) => account . error === null ) ,
53- [ displayState . notifications ] ,
64+ ( ) => visibleNotifications . every ( ( account ) => account . error === null ) ,
65+ [ visibleNotifications ] ,
5466 ) ;
5567
5668 if ( displayState . status === 'error' ) {
@@ -64,7 +76,7 @@ export const NotificationsRoute: FC = () => {
6476 return (
6577 < Page testId = "notifications" >
6678 < Contents paddingHorizontal = { false } >
67- { displayState . notifications . map ( ( accountNotification ) => {
79+ { visibleNotifications . map ( ( accountNotification ) => {
6880 return (
6981 < AccountNotifications
7082 account = { accountNotification . account }
0 commit comments