diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/lib/backend.js | 9 | ||||
| -rw-r--r-- | app/redux/connection/actions.js | 15 | ||||
| -rw-r--r-- | app/redux/connection/reducers.js | 5 |
3 files changed, 21 insertions, 8 deletions
diff --git a/app/lib/backend.js b/app/lib/backend.js index e5cf3765c4..bd0ca7ab63 100644 --- a/app/lib/backend.js +++ b/app/lib/backend.js @@ -227,15 +227,12 @@ export class Backend { }); } - connect(addr: string) { + connect(addr: string): Promise<void> { - this._store.dispatch(connectionActions.connectionChange({ - status: 'connecting', - serverAddress: addr, - })); + this._store.dispatch(connectionActions.connectingTo(addr)); - this._ipc.setCountry(addr) + return this._ipc.setCountry(addr) .then( () => { return this._ipc.connect(); }) diff --git a/app/redux/connection/actions.js b/app/redux/connection/actions.js index 0a7591fa11..7c808c8753 100644 --- a/app/redux/connection/actions.js +++ b/app/redux/connection/actions.js @@ -20,6 +20,10 @@ const copyIPAddress = () => { }; +type ConnectingAction = { + type: 'CONNECTING', + serverAddress: string, +}; type ConnectionChangeAction = { type: 'CONNECTION_CHANGE', @@ -42,7 +46,14 @@ type NewLocationAction = { newLocation: Location, }; -export type ConnectionAction = ConnectionChangeAction | NewPublicIpAction | NewLocationAction; +export type ConnectionAction = ConnectionChangeAction | NewPublicIpAction | NewLocationAction | ConnectingAction; + +function connectingTo(serverAddress: string): ConnectingAction { + return { + type: 'CONNECTING', + serverAddress: serverAddress, + }; +} function connectionChange(newData: $Shape<ConnectionReduxState>): ConnectionChangeAction { return { @@ -66,4 +77,4 @@ function newLocation(newLoc: Location): NewLocationAction { } -export default { connect, disconnect, copyIPAddress, connectionChange, newPublicIp, newLocation }; +export default { connect, disconnect, copyIPAddress, connectionChange, newPublicIp, newLocation, connectingTo }; diff --git a/app/redux/connection/reducers.js b/app/redux/connection/reducers.js index 7bf9abebc9..3c98ea2e4e 100644 --- a/app/redux/connection/reducers.js +++ b/app/redux/connection/reducers.js @@ -34,6 +34,11 @@ export default function(state: ConnectionReduxState = initialState, action: Redu return { ...state, ...{ clientIp: action.ip }}; case 'NEW_LOCATION': return { ...state, ...action.newLocation }; + case 'CONNECTING': + return { ...state, ...{ + status: 'connecting', + serverAddress: action.serverAddress, + }}; default: return state; } |
