From c925449db2a393cbdc5c0a67cf901e1efbc8ac52 Mon Sep 17 00:00:00 2001 From: Mikhail Mikheev Date: Tue, 23 Jun 2020 19:38:09 +0400 Subject: [PATCH] fix apps types, fix lastTimeUserLoggedInForSafes type --- src/routes/safe/components/Apps/index.tsx | 6 +++--- src/routes/safe/components/Apps/types.d.ts | 5 +++++ src/routes/safe/store/middleware/notificationsMiddleware.ts | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/routes/safe/components/Apps/index.tsx b/src/routes/safe/components/Apps/index.tsx index b4039f88..949e37f2 100644 --- a/src/routes/safe/components/Apps/index.tsx +++ b/src/routes/safe/components/Apps/index.tsx @@ -21,7 +21,7 @@ import { } from 'src/routes/safe/store/selectors' import { loadFromStorage, saveToStorage } from 'src/utils/storage' import { isSameHref } from 'src/utils/url' -import { SafeApp } from './types' +import { SafeApp, StoredSafeApp } from './types' const APPS_STORAGE_KEY = 'APPS_STORAGE_KEY' const APPS_LEGAL_DISCLAIMER_STORAGE_KEY = 'APPS_LEGAL_DISCLAIMER_STORAGE_KEY' @@ -195,7 +195,7 @@ function Apps({ closeModal, closeSnackbar, enqueueSnackbar, openModal }) { setAppList(copyAppList) // update storage list - const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] + const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] let storageApp = persistedAppList.find((a) => a.url === app.url) if (!storageApp) { @@ -303,7 +303,7 @@ function Apps({ closeModal, closeSnackbar, enqueueSnackbar, openModal }) { // recover apps from storage: // * third-party apps added by the user // * disabled status for both static and third-party apps - const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] + const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] const list = [...persistedAppList] staticAppsList.forEach((staticApp) => { diff --git a/src/routes/safe/components/Apps/types.d.ts b/src/routes/safe/components/Apps/types.d.ts index 635ba78f..8a8ead9b 100644 --- a/src/routes/safe/components/Apps/types.d.ts +++ b/src/routes/safe/components/Apps/types.d.ts @@ -6,3 +6,8 @@ export type SafeApp = { disabled?: boolean error: boolean } + +export type StoredSafeApp = { + url: string + disabled?: boolean +} diff --git a/src/routes/safe/store/middleware/notificationsMiddleware.ts b/src/routes/safe/store/middleware/notificationsMiddleware.ts index a28d76c7..48b752ae 100644 --- a/src/routes/safe/store/middleware/notificationsMiddleware.ts +++ b/src/routes/safe/store/middleware/notificationsMiddleware.ts @@ -38,7 +38,7 @@ const sendAwaitingTransactionNotification = async ( return } - let lastTimeUserLoggedInForSafes = (await loadFromStorage(LAST_TIME_USED_LOGGED_IN_ID)) || [] + let lastTimeUserLoggedInForSafes = (await loadFromStorage>(LAST_TIME_USED_LOGGED_IN_ID)) || {} const lastTimeUserLoggedIn = lastTimeUserLoggedInForSafes && lastTimeUserLoggedInForSafes[safeAddress] ? lastTimeUserLoggedInForSafes[safeAddress]