From f86e425e6ec47896da3904b69bcc8b48df0cfaf2 Mon Sep 17 00:00:00 2001 From: Joshen Lim Date: Tue, 7 Jun 2022 16:21:48 +0800 Subject: [PATCH] Fix error handling logic in use Notification hook --- studio/hooks/misc/useNotifications.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/studio/hooks/misc/useNotifications.tsx b/studio/hooks/misc/useNotifications.tsx index f0e817306c3..974bc388f9f 100644 --- a/studio/hooks/misc/useNotifications.tsx +++ b/studio/hooks/misc/useNotifications.tsx @@ -6,11 +6,12 @@ import { API_URL } from 'lib/constants' export const useNotifications = () => { const { data, error, mutate } = useSWR(`${API_URL}/notifications`, get) - const anyError = error !== undefined + + const anyError = (data as any)?.error || error !== undefined const refresh = () => mutate() return { - notifications: anyError ? undefined : data, + notifications: anyError ? [] : data, isLoading: !anyError && !data, isError: !!anyError, refresh,