Update state on retrieval success

This commit is contained in:
juampibermani 2021-05-31 15:08:43 -03:00
parent b566e91eaa
commit fc3da6f19f

View File

@ -24,13 +24,12 @@ const useAppList = (): UseAppListReturnType => {
useEffect(() => { useEffect(() => {
const loadAppsList = async () => { const loadAppsList = async () => {
setIsLoading(true) setIsLoading(true)
let result
try { try {
result = await fetchSafeAppsList() const result = await fetchSafeAppsList()
setApiAppsList(result && result?.apps.length ? result.apps : apiAppsList)
} catch (err) { } catch (err) {
dispatch(enqueueSnackbar(NOTIFICATIONS.SAFE_APPS_FETCH_ERROR_MSG)) dispatch(enqueueSnackbar(NOTIFICATIONS.SAFE_APPS_FETCH_ERROR_MSG))
} }
setApiAppsList(result && result?.length ? result : apiAppsList)
setIsLoading(false) setIsLoading(false)
} }