diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-08-30 10:46:25 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-08-30 10:46:25 +0200 |
| commit | 3fec3efd11bc8a73b6e9f9ea4b3bb28fdf9fd1e1 (patch) | |
| tree | 7ab4e7ee146a57a2bd75b3d125fe7f753bfffca1 /gui/src/main | |
| parent | 7b742357fa0200bf31b778ddb00971322aeb8a29 (diff) | |
| parent | 741bda934eb622a6ecc1b1101c7e59d69b1015bf (diff) | |
| download | mullvadvpn-3fec3efd11bc8a73b6e9f9ea4b3bb28fdf9fd1e1.tar.xz mullvadvpn-3fec3efd11bc8a73b6e9f9ea4b3bb28fdf9fd1e1.zip | |
Merge branch 'fix-change-window-type-autoconnect'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/index.ts | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 769863fd72..94702ce979 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -116,6 +116,7 @@ class ApplicationMain { private daemonRpc = new DaemonRpc(DAEMON_RPC_PATH); private daemonEventListener?: SubscriptionListener<DaemonEvent>; private reconnectBackoff = new ReconnectionBackoff(); + private beforeFirstDaemonConnection = true; private connectedToDaemon = false; private quitStage = AppQuitStage.unready; @@ -518,6 +519,8 @@ class ApplicationMain { } private onDaemonConnected = async () => { + const firstDaemonConnection = this.beforeFirstDaemonConnection; + this.beforeFirstDaemonConnection = false; this.connectedToDaemon = true; log.info('Connected to the daemon'); @@ -596,6 +599,10 @@ class ApplicationMain { IpcMainEventChannel.daemon.notifyConnected(this.windowController.webContents); } + if (firstDaemonConnection) { + void this.autoConnect(); + } + // show window when account is not set if (!this.settings.accountToken) { this.windowController?.show(); @@ -1389,13 +1396,25 @@ class ApplicationMain { } private async autoConnect() { - if (!this.accountData || !hasExpired(this.accountData.expiry)) { - try { - log.info('Auto-connecting the tunnel'); - await this.daemonRpc.connectTunnel(); - } catch (error) { - log.error(`Failed to auto-connect the tunnel: ${error.message}`); + if (process.env.NODE_ENV === 'development') { + log.info('Skip autoconnect in development'); + } else if ( + this.settings.accountToken && + (!this.accountData || !hasExpired(this.accountData.expiry)) + ) { + if (this.guiSettings.autoConnect) { + try { + log.info('Autoconnect the tunnel'); + + await this.daemonRpc.connectTunnel(); + } catch (error) { + log.error(`Failed to autoconnect the tunnel: ${error.message}`); + } + } else { + log.info('Skip autoconnect because GUI setting is disabled'); } + } else { + log.info('Skip autoconnect because account token is not set'); } } |
