From 65513955584fa0f9529317b8d765744f0b47b011 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 7 Aug 2024 09:00:25 -0400 Subject: [PATCH 1/2] fix: clear global error state on fetch Signed-off-by: Adam Setch --- src/hooks/useNotifications.ts | 1 + src/routes/Notifications.tsx | 8 +++++--- .../__snapshots__/Notifications.test.tsx.snap | 16 ++++++++-------- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/hooks/useNotifications.ts b/src/hooks/useNotifications.ts index a5f385ab2..a6d392938 100644 --- a/src/hooks/useNotifications.ts +++ b/src/hooks/useNotifications.ts @@ -60,6 +60,7 @@ export const useNotifications = (): NotificationsState => { const fetchNotifications = useCallback( async (state: GitifyState) => { setStatus('loading'); + setGlobalError(null); const fetchedNotifications = await getAllNotifications(state); diff --git a/src/routes/Notifications.tsx b/src/routes/Notifications.tsx index 17543e543..0e60f1a8f 100644 --- a/src/routes/Notifications.tsx +++ b/src/routes/Notifications.tsx @@ -4,10 +4,12 @@ import { AllRead } from '../components/AllRead'; import { Oops } from '../components/Oops'; import { AppContext } from '../context/App'; import { getAccountUUID } from '../utils/auth/utils'; +import { Errors } from '../utils/constants'; import { getNotificationCount } from '../utils/notifications'; export const NotificationsRoute: FC = () => { - const { notifications, globalError, settings } = useContext(AppContext); + const { notifications, status, globalError, settings } = + useContext(AppContext); const hasMultipleAccounts = useMemo( () => notifications.length > 1, @@ -24,8 +26,8 @@ export const NotificationsRoute: FC = () => { [notifications], ); - if (globalError) { - return ; + if (status === 'error') { + return ; } if (!hasNotifications && hasNoAccountErrors) { diff --git a/src/routes/__snapshots__/Notifications.test.tsx.snap b/src/routes/__snapshots__/Notifications.test.tsx.snap index 5dbd73147..b4e93dc86 100644 --- a/src/routes/__snapshots__/Notifications.test.tsx.snap +++ b/src/routes/__snapshots__/Notifications.test.tsx.snap @@ -75,13 +75,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- Oops + AllRead

, "container":

- Oops + AllRead

, "debug": [Function], @@ -213,13 +213,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- Oops + AllRead

, "container":

- Oops + AllRead

, "debug": [Function], @@ -282,13 +282,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- Oops + AllRead

, "container":

- Oops + AllRead

, "debug": [Function], @@ -351,13 +351,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- Oops + AllRead

, "container":

- Oops + AllRead

, "debug": [Function], From 0a4aeb4c280cba63489fe63f8224fb91a4680868 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Wed, 7 Aug 2024 09:03:38 -0400 Subject: [PATCH 2/2] fix: clear global error state on fetch Signed-off-by: Adam Setch --- .../__snapshots__/Notifications.test.tsx.snap | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/routes/__snapshots__/Notifications.test.tsx.snap b/src/routes/__snapshots__/Notifications.test.tsx.snap index b4e93dc86..8bb99d300 100644 --- a/src/routes/__snapshots__/Notifications.test.tsx.snap +++ b/src/routes/__snapshots__/Notifications.test.tsx.snap @@ -75,13 +75,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- AllRead + Oops

, "container":

- AllRead + Oops

, "debug": [Function], @@ -144,13 +144,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- AllRead + Oops

, "container":

- AllRead + Oops

, "debug": [Function], @@ -213,13 +213,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- AllRead + Oops

, "container":

- AllRead + Oops

, "debug": [Function], @@ -282,13 +282,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- AllRead + Oops

, "container":

- AllRead + Oops

, "debug": [Function], @@ -351,13 +351,13 @@ exports[`routes/Notifications.tsx should render itself & its children (error con "baseElement":

- AllRead + Oops

, "container":

- AllRead + Oops

, "debug": [Function],