From bcb468e3ec09782e75028a97eab3eb748798008d Mon Sep 17 00:00:00 2001 From: Agustin Pane Date: Fri, 19 Jun 2020 11:07:23 -0300 Subject: [PATCH] Fix race condition --- src/routes/load/container/Load.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/routes/load/container/Load.tsx b/src/routes/load/container/Load.tsx index 0fb69162..ece56987 100644 --- a/src/routes/load/container/Load.tsx +++ b/src/routes/load/container/Load.tsx @@ -16,17 +16,22 @@ import { SAFELIST_ADDRESS } from 'src/routes/routes' import { buildSafe } from 'src/routes/safe/store/actions/fetchSafe' import { history } from 'src/store' 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, +): Promise => { const safeProps = await buildSafe(safeAddress, safeName) safeProps.owners = owners - await addSafe(safeProps) - const storedSafes = (await loadFromStorage(SAFES_KEY)) || {} storedSafes[safeAddress] = safeProps - saveSafes(storedSafes) + await saveSafes(storedSafes) + await addSafe(safeProps) } class Load extends React.Component {