summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--app/lib/backend.js6
-rw-r--r--app/redux/account/actions.js15
-rw-r--r--app/redux/account/reducers.js7
-rw-r--r--test/reducers.spec.js15
4 files changed, 14 insertions, 29 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..ea0d369125 100644
--- a/app/redux/account/actions.js
+++ b/app/redux/account/actions.js
@@ -1,7 +1,6 @@
// @flow
import type { Backend, BackendError } from '../../lib/backend';
-import type { AccountReduxState } from './reducers.js';
type StartLoginAction = {
type: 'START_LOGIN',
@@ -16,15 +15,14 @@ type LoginFailedAction = {
error: BackendError,
};
-type LoginChangeAction = {
- type:'LOGIN_CHANGE',
- newData: $Shape<AccountReduxState>,
+type LoggedOutAction = {
+ type: 'LOGGED_OUT',
};
export type AccountAction = StartLoginAction
| LoginSuccessfulAction
| LoginFailedAction
- | LoginChangeAction;
+ | LoggedOutAction;
function startLogin(accountNumber?: string): StartLoginAction {
return {
@@ -47,14 +45,13 @@ function loginFailed(error: BackendError): LoginFailedAction {
};
}
-function loginChange(data: $Shape<AccountReduxState>): LoginChangeAction {
+function loggedOut(): LoggedOutAction {
return {
- type: 'LOGIN_CHANGE',
- newData: data,
+ 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, 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;
diff --git a/test/reducers.spec.js b/test/reducers.spec.js
index 23a8e91f89..236497a057 100644
--- a/test/reducers.spec.js
+++ b/test/reducers.spec.js
@@ -1,28 +1,13 @@
// @flow
import { expect } from 'chai';
-import accountReducer from '../app/redux/account/reducers';
import connectionReducer from '../app/redux/connection/reducers';
import settingsReducer from '../app/redux/settings/reducers';
import { defaultServer } from '../app/config';
-import { BackendError } from '../app/lib/backend';
describe('reducers', () => {
const previousState: any = {};
- it('should handle USER_LOGIN_CHANGE', () => {
- const action = {
- type: 'LOGIN_CHANGE',
- newData: {
- accountNumber: '1111',
- status: 'failed',
- error: new BackendError('INVALID_ACCOUNT')
- }
- };
- const test = Object.assign({}, action.newData);
- expect(accountReducer(previousState, action)).to.deep.equal(test);
- });
-
it('should handle CONNECTION_CHANGE', () => {
const action = {
type: 'CONNECTION_CHANGE',