diff options
| -rw-r--r-- | app/lib/backend.js | 6 | ||||
| -rw-r--r-- | app/redux/account/actions.js | 15 | ||||
| -rw-r--r-- | app/redux/account/reducers.js | 7 |
3 files changed, 21 insertions, 7 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index d36fc36d41..bc6eeeb8ff 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -214,11 +214,7 @@ export class Backend { this._ipc.setAccount('') .then(() => { - this._store.dispatch(accountActions.loginChange({ - status: 'none', - accountNumber: null, - paidUntil: null, - })); + this._store.dispatch(accountActions.loggedOut()); // disconnect user during logout return this.disconnect() diff --git a/app/redux/account/actions.js b/app/redux/account/actions.js index 288e06e857..55e37db2e9 100644 --- a/app/redux/account/actions.js +++ b/app/redux/account/actions.js @@ -16,6 +16,10 @@ type LoginFailedAction = { error: BackendError, }; +type LoggedOutAction = { + type: 'LOGGED_OUT', +}; + type LoginChangeAction = { type:'LOGIN_CHANGE', newData: $Shape<AccountReduxState>, @@ -24,7 +28,8 @@ type LoginChangeAction = { export type AccountAction = StartLoginAction | LoginSuccessfulAction | LoginFailedAction - | LoginChangeAction; + | LoginChangeAction + | LoggedOutAction; function startLogin(accountNumber?: string): StartLoginAction { return { @@ -54,7 +59,13 @@ function loginChange(data: $Shape<AccountReduxState>): LoginChangeAction { }; } +function loggedOut(): LoggedOutAction { + return { + type: 'LOGGED_OUT', + }; +} + const login = (backend: Backend, account: string) => () => backend.login(account); const logout = (backend: Backend) => () => backend.logout(); -export default { login, logout, loginChange, startLogin, loginSuccessful, loginFailed }; +export default { login, logout, loginChange, startLogin, loginSuccessful, loginFailed, loggedOut }; diff --git a/app/redux/account/reducers.js b/app/redux/account/reducers.js index dc2c985285..d6458e20dd 100644 --- a/app/redux/account/reducers.js +++ b/app/redux/account/reducers.js @@ -41,6 +41,13 @@ export default function(state: AccountReduxState = initialState, action: ReduxAc accountNumber: null, error: action.error, }}; + case 'LOGGED_OUT': + return { ...state, ...{ + status: 'none', + accountNumber: null, + paidUntil: null, + error: null, + }}; } return state; |
