Skip to content

Commit 2bf8b08

Browse files
authored
fix: clear global error state on fetch (#1443)
* fix: clear global error state on fetch Signed-off-by: Adam Setch <[email protected]> * fix: clear global error state on fetch Signed-off-by: Adam Setch <[email protected]> --------- Signed-off-by: Adam Setch <[email protected]>
1 parent 1aa979e commit 2bf8b08

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/hooks/useNotifications.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const useNotifications = (): NotificationsState => {
6060
const fetchNotifications = useCallback(
6161
async (state: GitifyState) => {
6262
setStatus('loading');
63+
setGlobalError(null);
6364

6465
const fetchedNotifications = await getAllNotifications(state);
6566

src/routes/Notifications.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { AllRead } from '../components/AllRead';
44
import { Oops } from '../components/Oops';
55
import { AppContext } from '../context/App';
66
import { getAccountUUID } from '../utils/auth/utils';
7+
import { Errors } from '../utils/constants';
78
import { getNotificationCount } from '../utils/notifications';
89

910
export const NotificationsRoute: FC = () => {
10-
const { notifications, globalError, settings } = useContext(AppContext);
11+
const { notifications, status, globalError, settings } =
12+
useContext(AppContext);
1113

1214
const hasMultipleAccounts = useMemo(
1315
() => notifications.length > 1,
@@ -24,8 +26,8 @@ export const NotificationsRoute: FC = () => {
2426
[notifications],
2527
);
2628

27-
if (globalError) {
28-
return <Oops error={globalError} />;
29+
if (status === 'error') {
30+
return <Oops error={globalError ?? Errors.UNKNOWN} />;
2931
}
3032

3133
if (!hasNotifications && hasNoAccountErrors) {

src/routes/__snapshots__/Notifications.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)