diff options
| author | Jonathan <jonathan@mullvad.net> | 2023-12-21 13:36:52 +0100 |
|---|---|---|
| committer | Jonathan <jonathan@mullvad.net> | 2023-12-21 13:36:52 +0100 |
| commit | 9d71eccc2f3507928b833f969c952347c7a76d4c (patch) | |
| tree | c92a6f524fa9f659a0edb2bb702e466d051ddba2 /gui/src/renderer | |
| parent | ce7f4f73f82295275631ef05dbe12ba17843ec2d (diff) | |
| parent | 8ed53a012b6c510a0dfd92925b8b0e742fd79da3 (diff) | |
| download | mullvadvpn-9d71eccc2f3507928b833f969c952347c7a76d4c.tar.xz mullvadvpn-9d71eccc2f3507928b833f969c952347c7a76d4c.zip | |
Merge branch 'out-ip-delay'
Diffstat (limited to 'gui/src/renderer')
| -rw-r--r-- | gui/src/renderer/app.tsx | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 584e80ed4f..b5eacf17b3 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -94,7 +94,6 @@ export default class AppRenderer { }; private location?: Partial<ILocation>; - private lastDisconnectedLocation?: Partial<ILocation>; private relayList?: IRelayListWithEndpointData; private tunnelState!: TunnelState; private settings!: ISettings; @@ -103,7 +102,6 @@ export default class AppRenderer { private previousLoginState: LoginState = 'none'; private loginScheduler = new Scheduler(); private connectedToDaemon = false; - private getLocationPromise?: Promise<ILocation>; constructor() { log.addOutput(new ConsoleOutput(LogLevel.debug)); @@ -255,7 +253,7 @@ export default class AppRenderer { ); } - void this.updateLocation(); + this.updateLocation(); if (initialState.navigationHistory) { // Set last action to POP to trigger automatic scrolling to saved coordinates. @@ -765,7 +763,7 @@ export default class AppRenderer { } // Update the location when entering a new tunnel state since it's likely changed. - void this.updateLocation(); + this.updateLocation(); }); } @@ -944,22 +942,16 @@ export default class AppRenderer { this.reduxActions.userInterface.setForceShowChanges(forceShowChanges); } - private async updateLocation() { + private updateLocation() { switch (this.tunnelState.state) { - case 'disconnected': { - if (this.lastDisconnectedLocation) { - this.setLocation(this.lastDisconnectedLocation); - } - const location = await this.fetchLocation(); - if (location) { - this.setLocation(location); - this.lastDisconnectedLocation = location; + case 'disconnected': + if (this.tunnelState.location) { + this.setLocation(this.tunnelState.location); } break; - } case 'disconnecting': - if (this.lastDisconnectedLocation) { - this.setLocation(this.lastDisconnectedLocation); + if (this.tunnelState.location) { + this.setLocation(this.tunnelState.location); } else { // If there's no previous location while disconnecting we remove the location. We keep the // coordinates to prevent the map from jumping around. @@ -968,38 +960,13 @@ export default class AppRenderer { } break; case 'connecting': - this.setLocation(this.tunnelState.details?.location ?? this.getLocationFromConstraints()); - break; case 'connected': { - if (this.tunnelState.details?.location) { - this.setLocation(this.tunnelState.details.location); - } - const location = await this.fetchLocation(); - if (location) { - this.setLocation(location); - } + this.setLocation(this.tunnelState.details?.location ?? this.getLocationFromConstraints()); break; } } } - private async fetchLocation(): Promise<ILocation | void> { - try { - // Fetch the new user location - const getLocationPromise = IpcRendererEventChannel.location.get(); - this.getLocationPromise = getLocationPromise; - const location = await getLocationPromise; - // If the location is currently unavailable, do nothing! This only ever happens when a - // custom relay is set or we are in a blocked state. - if (location && getLocationPromise === this.getLocationPromise) { - return location; - } - } catch (e) { - const error = e as Error; - log.error(`Failed to update the location: ${error.message}`); - } - } - private getLocationFromConstraints(): Partial<ILocation> { const state = this.reduxStore.getState(); const coordinates = { |
