Fix race condition

This commit is contained in:
Agustin Pane 2020-06-19 11:07:23 -03:00
parent fe7e4b5536
commit bcb468e3ec
1 changed files with 9 additions and 4 deletions

View File

@ -16,17 +16,22 @@ import { SAFELIST_ADDRESS } from 'src/routes/routes'
import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe' import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe'
import { history } from 'src/store' import { history } from 'src/store'
import { loadFromStorage } from 'src/utils/storage' import { loadFromStorage } from 'src/utils/storage'
import { Dispatch } from 'redux'
export const loadSafe = async (safeName, safeAddress, owners, addSafe) => { export const loadSafe = async (
safeName: string,
safeAddress: string,
owners: any,
addSafe: Dispatch<any>,
): Promise<void> => {
const safeProps = await buildSafe(safeAddress, safeName) const safeProps = await buildSafe(safeAddress, safeName)
safeProps.owners = owners safeProps.owners = owners
await addSafe(safeProps)
const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} const storedSafes = (await loadFromStorage(SAFES_KEY)) || {}
storedSafes[safeAddress] = safeProps storedSafes[safeAddress] = safeProps
saveSafes(storedSafes) await saveSafes(storedSafes)
await addSafe(safeProps)
} }
class Load extends React.Component<any> { class Load extends React.Component<any> {