fix apps types, fix lastTimeUserLoggedInForSafes type

This commit is contained in:
Mikhail Mikheev 2020-06-23 19:38:09 +04:00
parent 21ae4800c9
commit c925449db2
3 changed files with 9 additions and 4 deletions

View File

@ -21,7 +21,7 @@ import {
} from 'src/routes/safe/store/selectors' } from 'src/routes/safe/store/selectors'
import { loadFromStorage, saveToStorage } from 'src/utils/storage' import { loadFromStorage, saveToStorage } from 'src/utils/storage'
import { isSameHref } from 'src/utils/url' import { isSameHref } from 'src/utils/url'
import { SafeApp } from './types' import { SafeApp, StoredSafeApp } from './types'
const APPS_STORAGE_KEY = 'APPS_STORAGE_KEY' const APPS_STORAGE_KEY = 'APPS_STORAGE_KEY'
const APPS_LEGAL_DISCLAIMER_STORAGE_KEY = 'APPS_LEGAL_DISCLAIMER_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) setAppList(copyAppList)
// update storage list // update storage list
const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] const persistedAppList = (await loadFromStorage<StoredSafeApp[]>(APPS_STORAGE_KEY)) || []
let storageApp = persistedAppList.find((a) => a.url === app.url) let storageApp = persistedAppList.find((a) => a.url === app.url)
if (!storageApp) { if (!storageApp) {
@ -303,7 +303,7 @@ function Apps({ closeModal, closeSnackbar, enqueueSnackbar, openModal }) {
// recover apps from storage: // recover apps from storage:
// * third-party apps added by the user // * third-party apps added by the user
// * disabled status for both static and third-party apps // * disabled status for both static and third-party apps
const persistedAppList = (await loadFromStorage(APPS_STORAGE_KEY)) || [] const persistedAppList = (await loadFromStorage<StoredSafeApp[]>(APPS_STORAGE_KEY)) || []
const list = [...persistedAppList] const list = [...persistedAppList]
staticAppsList.forEach((staticApp) => { staticAppsList.forEach((staticApp) => {

View File

@ -6,3 +6,8 @@ export type SafeApp = {
disabled?: boolean disabled?: boolean
error: boolean error: boolean
} }
export type StoredSafeApp = {
url: string
disabled?: boolean
}

View File

@ -38,7 +38,7 @@ const sendAwaitingTransactionNotification = async (
return return
} }
let lastTimeUserLoggedInForSafes = (await loadFromStorage(LAST_TIME_USED_LOGGED_IN_ID)) || [] let lastTimeUserLoggedInForSafes = (await loadFromStorage<Record<string, string>>(LAST_TIME_USED_LOGGED_IN_ID)) || {}
const lastTimeUserLoggedIn = const lastTimeUserLoggedIn =
lastTimeUserLoggedInForSafes && lastTimeUserLoggedInForSafes[safeAddress] lastTimeUserLoggedInForSafes && lastTimeUserLoggedInForSafes[safeAddress]
? lastTimeUserLoggedInForSafes[safeAddress] ? lastTimeUserLoggedInForSafes[safeAddress]