From 6405c13da844184d24e1082254e4aa2692faa8c1 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Thu, 20 Sep 2018 23:04:03 +0200 Subject: [PATCH] move saving SessionStorage from component to SelectedAccountAction --- src/actions/SelectedAccountActions.js | 9 ++++++++- src/views/Wallet/views/AccountSend/Container.js | 3 --- src/views/Wallet/views/AccountSend/index.js | 2 -- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/actions/SelectedAccountActions.js b/src/actions/SelectedAccountActions.js index a89362d0..b587efc3 100644 --- a/src/actions/SelectedAccountActions.js +++ b/src/actions/SelectedAccountActions.js @@ -7,6 +7,9 @@ import * as SEND from 'actions/constants/send'; import * as NOTIFICATION from 'actions/constants/notification'; import * as PENDING from 'actions/constants/pendingTx'; +import * as SendFormActions from 'actions/SendFormActions'; +import * as SessionStorageActions from 'actions/SessionStorageActions'; + import * as stateUtils from 'reducers/utils'; import type { @@ -16,7 +19,7 @@ import type { Dispatch, State, } from 'flowtype'; -import * as SendFormActions from './SendFormActions'; + export type SelectedAccountAction = { @@ -42,6 +45,10 @@ export const updateSelectedValues = (prevState: State, action: Action): AsyncAct // SessionStorageActions.clear(location.pathname); } + if (prevState.sendForm !== state.sendForm) { + dispatch( SessionStorageActions.save() ); + } + // handle devices state change (from trezor-connect events or location change) if (locationChange || prevState.accounts !== state.accounts diff --git a/src/views/Wallet/views/AccountSend/Container.js b/src/views/Wallet/views/AccountSend/Container.js index 0dee8fbc..14135764 100644 --- a/src/views/Wallet/views/AccountSend/Container.js +++ b/src/views/Wallet/views/AccountSend/Container.js @@ -7,7 +7,6 @@ import { connect } from 'react-redux'; import { reconnect } from 'actions/DiscoveryActions'; import SendFormActions from 'actions/SendFormActions'; -import * as SessionStorageActions from 'actions/SessionStorageActions'; import type { MapStateToProps, MapDispatchToProps } from 'react-redux'; import type { State, Dispatch } from 'flowtype'; import type { StateProps as BaseStateProps, DispatchProps as BaseDispatchProps } from 'views/Wallet/components/SelectedAccount'; @@ -24,7 +23,6 @@ export type StateProps = BaseStateProps & { export type DispatchProps = BaseDispatchProps & { sendFormActions: typeof SendFormActions, - saveSessionStorage: typeof SessionStorageActions.save } export type Props = StateProps & BaseStateProps & DispatchProps & BaseDispatchProps; @@ -43,7 +41,6 @@ const mapStateToProps: MapStateToProps = (state: St const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch): DispatchProps => ({ blockchainReconnect: bindActionCreators(reconnect, dispatch), sendFormActions: bindActionCreators(SendFormActions, dispatch), - saveSessionStorage: bindActionCreators(SessionStorageActions.save, dispatch), }); export default connect(mapStateToProps, mapDispatchToProps)(AccountSend); \ No newline at end of file diff --git a/src/views/Wallet/views/AccountSend/index.js b/src/views/Wallet/views/AccountSend/index.js index 6e213606..9e7d292a 100644 --- a/src/views/Wallet/views/AccountSend/index.js +++ b/src/views/Wallet/views/AccountSend/index.js @@ -180,8 +180,6 @@ class AccountSend extends Component { componentWillReceiveProps(newProps: Props) { calculate(this.props, newProps); validation(newProps); - - this.props.saveSessionStorage(); } getAddressInputState(address: string, addressErrors: string, addressWarnings: string) {