From b67315e1804861b5070058c0d48f9e80033b5df2 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Mon, 28 May 2018 19:48:07 +0200 Subject: [PATCH] dispose and initialization selectedAccount view --- src/js/actions/SelectedAccountActions.js | 32 ++++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/js/actions/SelectedAccountActions.js b/src/js/actions/SelectedAccountActions.js index 5da4cf99..cb082f20 100644 --- a/src/js/actions/SelectedAccountActions.js +++ b/src/js/actions/SelectedAccountActions.js @@ -54,6 +54,20 @@ export const updateSelectedValues = (prevState: State, action: Action): AsyncAct || prevState.tokens !== state.tokens || prevState.pending !== state.pending || prevState.web3 !== state.web3) { + + + if (locationChange) { + + if (prevLocation) { + // save form data to session storage + // TODO: move to state.sendForm on change event + if (prevLocation.state.send) { + SessionStorageActions.save(prevState.router.location.pathname, state.sendForm); + } + } + // dispose current account view + dispatch( dispose() ); + } const account = stateUtils.getSelectedAccount(state); const network = stateUtils.getSelectedNetwork(state); @@ -84,23 +98,9 @@ export const updateSelectedValues = (prevState: State, action: Action): AsyncAct type: ACCOUNT.UPDATE_SELECTED_ACCOUNT, payload, }); - } - if (locationChange) { - - if (prevLocation) { - // save form data to session storage - // TODO: move to state.sendForm on change event - if (prevLocation.state.send) { - SessionStorageActions.save(prevState.router.location.pathname, state.sendForm); - } - } - - dispatch( dispose() ); - } - - if (needUpdate) { - if (location.state.send && state.sendForm.currency === "") { + // initialize SendFormReducer + if (location.state.send && getState().sendForm.currency === "") { dispatch( SendFormActions.init( SessionStorageActions.load(location.pathname) ) ); } }