Fix addressbook type errors
This commit is contained in:
parent
18f03b8bc1
commit
e7c012d5d1
|
@ -1,6 +1,12 @@
|
||||||
import { Record } from 'immutable'
|
import { Record } from 'immutable'
|
||||||
|
|
||||||
export const makeAddressBookEntry = Record({
|
export interface AddressBookEntryProps {
|
||||||
|
address: string
|
||||||
|
name: string
|
||||||
|
isOwner: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const makeAddressBookEntry = Record<AddressBookEntryProps>({
|
||||||
address: '',
|
address: '',
|
||||||
name: '',
|
name: '',
|
||||||
isOwner: false,
|
isOwner: false,
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { List, Map } from 'immutable'
|
import { List } from 'immutable'
|
||||||
|
|
||||||
import { loadAddressBook } from 'src/logic/addressBook/store/actions/loadAddressBook'
|
import { loadAddressBook } from 'src/logic/addressBook/store/actions/loadAddressBook'
|
||||||
import { buildAddressBook } from 'src/logic/addressBook/store/reducer/addressBook'
|
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) => {
|
const loadAddressBookFromStorage = () => async (dispatch, getState) => {
|
||||||
try {
|
try {
|
||||||
const state = getState()
|
const state = getState()
|
||||||
let addressBook = await getAddressBookFromStorage()
|
let storedAdBk = await getAddressBookFromStorage()
|
||||||
if (!addressBook) {
|
if (!storedAdBk) {
|
||||||
addressBook = Map([])
|
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
|
// 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 safes = safesListSelector(state)
|
||||||
const adbkEntries = addressBook.keySeq().toArray()
|
const adbkEntries = addressBook.keySeq().toArray()
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { loadFromStorage, saveToStorage } from 'src/utils/storage'
|
import { loadFromStorage, saveToStorage } from 'src/utils/storage'
|
||||||
|
import { AddressBookEntryProps } from './../model/addressBook'
|
||||||
|
|
||||||
const ADDRESS_BOOK_STORAGE_KEY = 'ADDRESS_BOOK_STORAGE_KEY'
|
const ADDRESS_BOOK_STORAGE_KEY = 'ADDRESS_BOOK_STORAGE_KEY'
|
||||||
|
|
||||||
export const getAddressBookFromStorage = async () => {
|
export const getAddressBookFromStorage = async (): Promise<Array<AddressBookEntryProps> | undefined> => {
|
||||||
const data = await loadFromStorage(ADDRESS_BOOK_STORAGE_KEY)
|
const data = await loadFromStorage<Array<AddressBookEntryProps>>(ADDRESS_BOOK_STORAGE_KEY)
|
||||||
|
|
||||||
return data || []
|
return data
|
||||||
}
|
}
|
||||||
|
|
||||||
export const saveAddressBook = async (addressBook) => {
|
export const saveAddressBook = async (addressBook) => {
|
||||||
|
|
Loading…
Reference in New Issue