File tree Expand file tree Collapse file tree 1 file changed +18
-14
lines changed
Expand file tree Collapse file tree 1 file changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -73,22 +73,26 @@ export const useNotifications = (): NotificationsState => {
7373 const fetchedNotifications = await getAllNotifications ( state ) ;
7474
7575 // Set Global Error if all accounts have the same error
76- const allAccountsHaveErrors = fetchedNotifications . every ( ( account ) => {
77- return account . error !== null ;
78- } ) ;
79- let accountErrorsAreAllSame = true ;
80- const accountError = fetchedNotifications [ 0 ] ?. error ;
81- for ( const fetchedNotification of fetchedNotifications ) {
82- if ( accountError !== fetchedNotification . error ) {
83- accountErrorsAreAllSame = false ;
84- break ;
76+ if ( fetchNotifications . length > 0 ) {
77+ const allAccountsHaveErrors = fetchedNotifications . every ( ( account ) => {
78+ return account . error !== null ;
79+ } ) ;
80+
81+ let accountErrorsAreAllSame = true ;
82+ const accountError = fetchedNotifications [ 0 ] ?. error ;
83+
84+ for ( const fetchedNotification of fetchedNotifications ) {
85+ if ( accountError !== fetchedNotification . error ) {
86+ accountErrorsAreAllSame = false ;
87+ break ;
88+ }
8589 }
86- }
8790
88- if ( allAccountsHaveErrors ) {
89- setStatus ( 'error' ) ;
90- setGlobalError ( accountErrorsAreAllSame ? accountError : null ) ;
91- return ;
91+ if ( allAccountsHaveErrors ) {
92+ setStatus ( 'error' ) ;
93+ setGlobalError ( accountErrorsAreAllSame ? accountError : null ) ;
94+ return ;
95+ }
9296 }
9397
9498 setNotifications ( fetchedNotifications ) ;
You can’t perform that action at this time.
0 commit comments