diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-03-08 11:37:22 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-03-09 11:00:00 +0100 |
| commit | dd98011e166ceda47c4e7c5858fb173ecc58c2d3 (patch) | |
| tree | 0f04604c1f43388da0097ca1bdb2e539d92a6f46 /gui/src/main | |
| parent | 053c599aa29be2d597ecb82b31829fa9eb8fb761 (diff) | |
| download | mullvadvpn-dd98011e166ceda47c4e7c5858fb173ecc58c2d3.tar.xz mullvadvpn-dd98011e166ceda47c4e7c5858fb173ecc58c2d3.zip | |
Keep daemon connection state in main process only
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/index.ts | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 190f575e94..df41037d2c 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -559,9 +559,10 @@ class ApplicationMain { // reset the reconnect backoff when connection established. this.reconnectBackoff.reset(); - // notify renderer - if (this.windowController) { - IpcMainEventChannel.daemonConnected.notify(this.windowController.webContents); + // notify renderer, this.connectedToDaemon could have changed if the daemon disconnected again + // before this if-statement is reached. + if (this.windowController && this.connectedToDaemon) { + IpcMainEventChannel.daemon.notifyConnected(this.windowController.webContents); } // show window when account is not set @@ -581,9 +582,6 @@ class ApplicationMain { // Reset the daemon event listener since it's going to be invalidated on disconnect this.daemonEventListener = undefined; - // TODO: GRPC doesn't set an error, but without an error, the UI won't be updated - error = error === undefined && wasConnected ? new Error('Connection to daemon lost') : error; - if (wasConnected) { this.connectedToDaemon = false; @@ -592,10 +590,7 @@ class ApplicationMain { // notify renderer process if (this.windowController) { - IpcMainEventChannel.daemonDisconnected.notify( - this.windowController.webContents, - error ? error.message : undefined, - ); + IpcMainEventChannel.daemon.notifyDisconnected(this.windowController.webContents); } } |
