diff options
| author | Erik Larkö <erik@mullvad.net> | 2017-07-25 13:28:05 +0200 |
|---|---|---|
| committer | Erik Larkö <erik@mullvad.net> | 2017-08-08 09:50:58 +0200 |
| commit | 3ec32f23e93c8a487da82db86516ad12782b54f6 (patch) | |
| tree | 1ca272253ff2b242bca265c13dd4b3c260bc62a7 /app | |
| parent | d375be8e56975d57f1ca67f28459609de6c10fa5 (diff) | |
| download | mullvadvpn-3ec32f23e93c8a487da82db86516ad12782b54f6.tar.xz mullvadvpn-3ec32f23e93c8a487da82db86516ad12782b54f6.zip | |
Added NEW_LOCATION action
Diffstat (limited to 'app')
| -rw-r--r-- | app/lib/backend.js | 2 | ||||
| -rw-r--r-- | app/redux/connection/actions.js | 24 | ||||
| -rw-r--r-- | app/redux/connection/reducers.js | 2 |
3 files changed, 25 insertions, 3 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index bc6eeeb8ff..e5cf3765c4 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -112,7 +112,7 @@ export class Backend { country: location.country, city: location.city }; - this._store.dispatch(connectionActions.connectionChange(newLocation)); + this._store.dispatch(connectionActions.newLocation(newLocation)); }) .catch(e => { log.info('Failed getting new location', e); diff --git a/app/redux/connection/actions.js b/app/redux/connection/actions.js index 142feb9d79..0a7591fa11 100644 --- a/app/redux/connection/actions.js +++ b/app/redux/connection/actions.js @@ -5,6 +5,7 @@ import { clipboard } from 'electron'; import type { Backend } from '../../lib/backend'; import type { ConnectionReduxState } from './reducers.js'; import type { ReduxGetState, ReduxDispatch } from '../store'; +import type { Coordinate2d } from '../../types'; const connect = (backend: Backend, addr: string) => () => backend.connect(addr); @@ -24,11 +25,24 @@ type ConnectionChangeAction = { type: 'CONNECTION_CHANGE', newData: $Shape<ConnectionReduxState>, }; + type NewPublicIpAction = { type: 'NEW_PUBLIC_IP', ip: string, }; -export type ConnectionAction = ConnectionChangeAction | NewPublicIpAction; + +type Location = { + location: Coordinate2d, + country: string, + city: string, +}; + +type NewLocationAction = { + type: 'NEW_LOCATION', + newLocation: Location, +}; + +export type ConnectionAction = ConnectionChangeAction | NewPublicIpAction | NewLocationAction; function connectionChange(newData: $Shape<ConnectionReduxState>): ConnectionChangeAction { return { @@ -44,6 +58,12 @@ function newPublicIp(ip: string): NewPublicIpAction { }; } +function newLocation(newLoc: Location): NewLocationAction { + return { + type: 'NEW_LOCATION', + newLocation: newLoc, + }; +} -export default { connect, disconnect, copyIPAddress, connectionChange, newPublicIp }; +export default { connect, disconnect, copyIPAddress, connectionChange, newPublicIp, newLocation }; diff --git a/app/redux/connection/reducers.js b/app/redux/connection/reducers.js index 2426f7eddd..7bf9abebc9 100644 --- a/app/redux/connection/reducers.js +++ b/app/redux/connection/reducers.js @@ -32,6 +32,8 @@ export default function(state: ConnectionReduxState = initialState, action: Redu return { ...state, ...action.newData }; case 'NEW_PUBLIC_IP': return { ...state, ...{ clientIp: action.ip }}; + case 'NEW_LOCATION': + return { ...state, ...action.newLocation }; default: return state; } |
