diff options
Diffstat (limited to 'gui/src')
| -rw-r--r-- | gui/src/main/index.ts | 15 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 25 | ||||
| -rw-r--r-- | gui/src/shared/ipc-schema.ts | 8 |
3 files changed, 13 insertions, 35 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); } } diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 4c79cc2192..9f7c6b5d2b 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -93,7 +93,6 @@ export default class AppRenderer { private tunnelState!: TunnelState; private settings!: ISettings; private guiSettings!: IGuiSettingsState; - private connectedToDaemon = false; private autoConnected = false; private doingLogin = false; private loginTimer?: NodeJS.Timeout; @@ -108,12 +107,12 @@ export default class AppRenderer { } }); - IpcRendererEventChannel.daemonConnected.listen(() => { + IpcRendererEventChannel.daemon.listenConnected(() => { consumePromise(this.onDaemonConnected()); }); - IpcRendererEventChannel.daemonDisconnected.listen((errorMessage?: string) => { - this.onDaemonDisconnected(errorMessage ? new Error(errorMessage) : undefined); + IpcRendererEventChannel.daemon.listenDisconnected(() => { + this.onDaemonDisconnected(); }); IpcRendererEventChannel.account.listen((newAccountData?: IAccountData) => { @@ -559,14 +558,6 @@ export default class AppRenderer { } private async onDaemonConnected() { - // Filter out the calls coming from IPC events arriving right after the constructor finished - // execution. - if (this.connectedToDaemon) { - return; - } - - this.connectedToDaemon = true; - if (this.settings.accountToken) { this.history.resetWith('/connect'); @@ -577,14 +568,8 @@ export default class AppRenderer { } } - private onDaemonDisconnected(error?: Error) { - const wasConnected = this.connectedToDaemon; - - this.connectedToDaemon = false; - - if (error && wasConnected) { - this.history.resetWith('/'); - } + private onDaemonDisconnected() { + this.history.resetWith('/'); } private async autoConnect() { diff --git a/gui/src/shared/ipc-schema.ts b/gui/src/shared/ipc-schema.ts index 62a3afc948..3f0d86d995 100644 --- a/gui/src/shared/ipc-schema.ts +++ b/gui/src/shared/ipc-schema.ts @@ -107,11 +107,9 @@ export const ipcSchema = { windowFocus: { '': notifyRenderer<boolean>(), }, - daemonConnected: { - '': notifyRenderer<void>(), - }, - daemonDisconnected: { - '': notifyRenderer<string | undefined>(), + daemon: { + connected: notifyRenderer<void>(), + disconnected: notifyRenderer<void>(), }, location: { '': notifyRenderer<ILocation>(), |
