diff --git a/src/components/savedAccounts/index.js b/src/components/savedAccounts/index.js index 85f72caa1d9..acd61cfc21d 100644 --- a/src/components/savedAccounts/index.js +++ b/src/components/savedAccounts/index.js @@ -2,6 +2,7 @@ import { connect } from 'react-redux'; import { withRouter } from 'react-router'; import { translate } from 'react-i18next'; import { accountRemoved, accountSwitched } from '../../actions/savedAccounts'; +import { accountLoggedOut } from '../../actions/account'; import SavedAccounts from './savedAccounts'; const mapStateToProps = state => ({ @@ -12,6 +13,7 @@ const mapStateToProps = state => ({ const mapDispatchToProps = dispatch => ({ accountRemoved: data => dispatch(accountRemoved(data)), accountSwitched: data => dispatch(accountSwitched(data)), + accountLoggedOut: () => dispatch(accountLoggedOut()), }); export default connect( diff --git a/src/components/savedAccounts/savedAccounts.js b/src/components/savedAccounts/savedAccounts.js index d5a7447ab12..0dcc7618094 100644 --- a/src/components/savedAccounts/savedAccounts.js +++ b/src/components/savedAccounts/savedAccounts.js @@ -31,6 +31,10 @@ class SavedAccounts extends React.Component { } toggleEdit() { + if (this.props.savedAccounts.length === 0) { + this.props.accountLoggedOut(); + } + this.setState({ editing: !this.state.editing, accountSelectedForRemove: null, diff --git a/src/store/reducers/peers.js b/src/store/reducers/peers.js index 3aa5a33b494..783fad32004 100644 --- a/src/store/reducers/peers.js +++ b/src/store/reducers/peers.js @@ -18,8 +18,6 @@ const peers = (state = { status: {}, options: {} }, action) => { }); case actionTypes.activePeerUpdate: return Object.assign({}, state, { status: action.data }); - case actionTypes.accountLoggedOut: - return Object.assign({}, state, { data: {}, status: {}, options: {} }); default: return state; } diff --git a/src/store/reducers/peers.test.js b/src/store/reducers/peers.test.js index a4ef9f75932..6036e97d4bd 100644 --- a/src/store/reducers/peers.test.js +++ b/src/store/reducers/peers.test.js @@ -33,25 +33,5 @@ describe('Reducer: peers(state, action)', () => { const changedState = peers(state, action); expect(changedState).to.deep.equal(newState); }); - - it('should return and empty state object if action is accountLoggedOut', () => { - const state = { - data: { - currentPeer: 'localhost', - port: 4000, - options: { - name: 'Custom Node', - }, - }, - status: { online: true }, - }; - const action = { - type: actionTypes.accountLoggedOut, - }; - - const newState = { status: {}, data: {}, options: {} }; - const changedState = peers(state, action); - expect(changedState).to.deep.equal(newState); - }); });