From fc3da6f19f3d031e0c68dfea738c828fde44f804 Mon Sep 17 00:00:00 2001 From: juampibermani Date: Mon, 31 May 2021 15:08:43 -0300 Subject: [PATCH] Update state on retrieval success --- src/routes/safe/components/Apps/hooks/useAppList.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/routes/safe/components/Apps/hooks/useAppList.ts b/src/routes/safe/components/Apps/hooks/useAppList.ts index 7f76e9d5..c52bd7d2 100644 --- a/src/routes/safe/components/Apps/hooks/useAppList.ts +++ b/src/routes/safe/components/Apps/hooks/useAppList.ts @@ -24,13 +24,12 @@ const useAppList = (): UseAppListReturnType => { useEffect(() => { const loadAppsList = async () => { setIsLoading(true) - let result try { - result = await fetchSafeAppsList() + const result = await fetchSafeAppsList() + setApiAppsList(result && result?.apps.length ? result.apps : apiAppsList) } catch (err) { dispatch(enqueueSnackbar(NOTIFICATIONS.SAFE_APPS_FETCH_ERROR_MSG)) } - setApiAppsList(result && result?.length ? result : apiAppsList) setIsLoading(false) }