diff --git a/src/logic/addressBook/model/addressBook.ts b/src/logic/addressBook/model/addressBook.ts index fb4fd19f..f051fe18 100644 --- a/src/logic/addressBook/model/addressBook.ts +++ b/src/logic/addressBook/model/addressBook.ts @@ -1,6 +1,12 @@ import { Record } from 'immutable' -export const makeAddressBookEntry = Record({ +export interface AddressBookEntryProps { + address: string + name: string + isOwner: boolean +} + +export const makeAddressBookEntry = Record({ address: '', name: '', isOwner: false, diff --git a/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts b/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts index 20cfe570..88009c78 100644 --- a/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts +++ b/src/logic/addressBook/store/actions/loadAddressBookFromStorage.ts @@ -1,4 +1,4 @@ -import { List, Map } from 'immutable' +import { List } from 'immutable' import { loadAddressBook } from 'src/logic/addressBook/store/actions/loadAddressBook' import { buildAddressBook } from 'src/logic/addressBook/store/reducer/addressBook' @@ -8,11 +8,12 @@ import { safesListSelector } from 'src/routes/safe/store/selectors' const loadAddressBookFromStorage = () => async (dispatch, getState) => { try { const state = getState() - let addressBook = await getAddressBookFromStorage() - if (!addressBook) { - addressBook = Map([]) + let storedAdBk = await getAddressBookFromStorage() + if (!storedAdBk) { + storedAdBk = [] } - addressBook = buildAddressBook(addressBook) + + let addressBook = buildAddressBook(storedAdBk) // Fetch all the current safes, in case that we don't have a safe on the adbk, we add it const safes = safesListSelector(state) const adbkEntries = addressBook.keySeq().toArray() diff --git a/src/logic/addressBook/utils/index.ts b/src/logic/addressBook/utils/index.ts index b0131480..7fb48374 100644 --- a/src/logic/addressBook/utils/index.ts +++ b/src/logic/addressBook/utils/index.ts @@ -1,11 +1,12 @@ import { loadFromStorage, saveToStorage } from 'src/utils/storage' +import { AddressBookEntryProps } from './../model/addressBook' const ADDRESS_BOOK_STORAGE_KEY = 'ADDRESS_BOOK_STORAGE_KEY' -export const getAddressBookFromStorage = async () => { - const data = await loadFromStorage(ADDRESS_BOOK_STORAGE_KEY) +export const getAddressBookFromStorage = async (): Promise | undefined> => { + const data = await loadFromStorage>(ADDRESS_BOOK_STORAGE_KEY) - return data || [] + return data } export const saveAddressBook = async (addressBook) => {