diff options
| author | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-28 18:48:27 +0000 |
|---|---|---|
| committer | Janito Vaqueiro Ferreira Filho <janito@mullvad.net> | 2019-06-28 19:18:45 +0000 |
| commit | 2185ba222098cca1f802c6d3e3acb9a4a3f49f2d (patch) | |
| tree | 145b7c8083be620ff8c7274b613e14caf58aeb14 /gui/src | |
| parent | 09bbf7dc4f89c8faa0c536b7046813afa15d4d82 (diff) | |
| download | mullvadvpn-2185ba222098cca1f802c6d3e3acb9a4a3f49f2d.tar.xz mullvadvpn-2185ba222098cca1f802c6d3e3acb9a4a3f49f2d.zip | |
Use broadcasted location in GUI
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/index.ts | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 5bf4d5f384..9013c7c5cd 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -724,16 +724,24 @@ class ApplicationMain { } private async updateLocation() { - const state = this.tunnelState.state; + const tunnelState = this.tunnelState; - if (state === 'connected' || state === 'disconnected' || state === 'connecting') { - try { - // It may take some time to fetch the new user location. - // So take the user to the last known location when disconnected. - if (state === 'disconnected' && this.lastDisconnectedLocation) { - this.setLocation(this.lastDisconnectedLocation); - } + if (tunnelState.state === 'connected' || tunnelState.state === 'connecting') { + // Location was broadcasted with the tunnel state, but it doesn't contain the relay out IP + // address, so it will have to be fetched afterwards + if (tunnelState.details) { + this.setLocation(tunnelState.details.location); + } + } else if (tunnelState.state === 'disconnected') { + // It may take some time to fetch the new user location. + // So take the user to the last known location when disconnected. + if (this.lastDisconnectedLocation) { + this.setLocation(this.lastDisconnectedLocation); + } + } + if (tunnelState.state === 'connected' || tunnelState.state === 'disconnected') { + try { // Fetch the new user location const location = await this.daemonRpc.getLocation(); // If the location is currently unavailable, do nothing! This only ever @@ -751,7 +759,7 @@ class ApplicationMain { // Broadcast the new location. // There is a chance that the location is not stale if the tunnel state before the location // request is the same as after receiving the response. - if (this.tunnelState.state === state) { + if (this.tunnelState.state === tunnelState.state) { this.setLocation(location); } } catch (error) { |
