diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-07-25 10:30:36 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-07-28 07:29:41 +0200 |
| commit | 8df67c161683773092668130deec3f50c23b9205 (patch) | |
| tree | 7f2f9b8ae3f2c2927345b31c86465464b538e923 /app | |
| parent | fd803f74404a1a10f290cbd0852c4ee9a1b2d7ae (diff) | |
| download | mullvadvpn-8df67c161683773092668130deec3f50c23b9205.tar.xz mullvadvpn-8df67c161683773092668130deec3f50c23b9205.zip | |
Added NEW_PUBLIC_IP action
Diffstat (limited to 'app')
| -rw-r--r-- | app/lib/backend.js | 2 | ||||
| -rw-r--r-- | app/redux/connection/actions.js | 18 | ||||
| -rw-r--r-- | app/redux/connection/reducers.js | 9 | ||||
| -rw-r--r-- | app/redux/store.js | 5 |
4 files changed, 26 insertions, 8 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index c8bea1600b..3c322afa6d 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -98,7 +98,7 @@ export class Backend { this._ipc.getIp() .then( ip => { log.info('Got ip', ip); - this._store.dispatch(connectionActions.connectionChange({ clientIp: ip })); + this._store.dispatch(connectionActions.newPublicIp(ip)); }) .catch(e => { log.info('Failed syncing with the backend', e); diff --git a/app/redux/connection/actions.js b/app/redux/connection/actions.js index 9f573bede2..142feb9d79 100644 --- a/app/redux/connection/actions.js +++ b/app/redux/connection/actions.js @@ -19,10 +19,16 @@ const copyIPAddress = () => { }; -export type ConnectionChangeAction = { + +type ConnectionChangeAction = { type: 'CONNECTION_CHANGE', newData: $Shape<ConnectionReduxState>, }; +type NewPublicIpAction = { + type: 'NEW_PUBLIC_IP', + ip: string, +}; +export type ConnectionAction = ConnectionChangeAction | NewPublicIpAction; function connectionChange(newData: $Shape<ConnectionReduxState>): ConnectionChangeAction { return { @@ -31,5 +37,13 @@ function connectionChange(newData: $Shape<ConnectionReduxState>): ConnectionChan }; } +function newPublicIp(ip: string): NewPublicIpAction { + return { + type: 'NEW_PUBLIC_IP', + ip: ip, + }; +} + + -export default { connect, disconnect, copyIPAddress, connectionChange }; +export default { connect, disconnect, copyIPAddress, connectionChange, newPublicIp }; diff --git a/app/redux/connection/reducers.js b/app/redux/connection/reducers.js index 07bdf20b16..2426f7eddd 100644 --- a/app/redux/connection/reducers.js +++ b/app/redux/connection/reducers.js @@ -27,9 +27,12 @@ const initialState: ConnectionReduxState = { export default function(state: ConnectionReduxState = initialState, action: ReduxAction): ConnectionReduxState { - if (action.type === 'CONNECTION_CHANGE') { + switch (action.type) { + case 'CONNECTION_CHANGE': return { ...state, ...action.newData }; + case 'NEW_PUBLIC_IP': + return { ...state, ...{ clientIp: action.ip }}; + default: + return state; } - - return state; } diff --git a/app/redux/store.js b/app/redux/store.js index 93b748ed7a..0a72a1869a 100644 --- a/app/redux/store.js +++ b/app/redux/store.js @@ -16,7 +16,7 @@ import type { AccountReduxState } from './account/reducers.js'; import type { ConnectionReduxState } from './connection/reducers.js'; import type { SettingsReduxState } from './settings/reducers.js'; -import type { ConnectionChangeAction } from './connection/actions.js'; +import type { ConnectionAction } from './connection/actions.js'; import type { LoginChangeAction } from './account/actions.js'; import type { UpdateSettingsAction } from './settings/actions.js'; @@ -28,7 +28,8 @@ export type ReduxState = { export type ReduxAction = LoginChangeAction | UpdateSettingsAction - | ConnectionChangeAction; + | ConnectionAction; + export type ReduxStore = Store<ReduxState, ReduxAction, ReduxDispatch>; export type ReduxGetState = () => ReduxState; export type ReduxDispatch = (action: ReduxAction | ReduxThunk) => any; |
