diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-03-14 09:43:42 +0100 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-03-14 09:43:42 +0100 |
| commit | b9786c514978012a9c91089ea3008075316eb25a (patch) | |
| tree | d209c1394591935284ae36de6404c0e19d68ed68 | |
| parent | 5cf2e320362a65ac8790f578bd1765c6e47d4eb7 (diff) | |
| parent | a43ff8d7b66e1b476b0714dbf27b7b9b8e40da85 (diff) | |
| download | mullvadvpn-b9786c514978012a9c91089ea3008075316eb25a.tar.xz mullvadvpn-b9786c514978012a9c91089ea3008075316eb25a.zip | |
Merge branch 'fix-daemon-connection-race'
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | gui/src/renderer/app.tsx | 35 |
2 files changed, 23 insertions, 13 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ffd8d025d..e9dc017d97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ Line wrap the file at 100 chars. Th ### Fixed - Fix delay in showing/hiding update notification when toggling beta program. - Improve responsiveness when reconnecting after some failed connection attempts. +- Fix GUI not showing correct view if disconnected from the daemon during app startup. #### Windows - Fix "cannot find the file" error while creating a Wintun adapter by upgrading Wintun. diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx index 9f7c6b5d2b..495cd2dc7c 100644 --- a/gui/src/renderer/app.tsx +++ b/gui/src/renderer/app.tsx @@ -96,6 +96,7 @@ export default class AppRenderer { private autoConnected = false; private doingLogin = false; private loginTimer?: NodeJS.Timeout; + private connectedToDaemon = false; constructor() { log.addOutput(new ConsoleOutput(LogLevel.debug)); @@ -493,7 +494,11 @@ export default class AppRenderer { private redirectToConnect() { // Redirect the user after some time to allow for the 'Logged in' screen to be visible - this.loginTimer = global.setTimeout(() => this.history.resetWith('/connect'), 1000); + this.loginTimer = global.setTimeout(() => { + if (this.connectedToDaemon) { + this.history.resetWith('/connect'); + } + }, 1000); } private setLocale(locale: string) { @@ -558,6 +563,7 @@ export default class AppRenderer { } private async onDaemonConnected() { + this.connectedToDaemon = true; if (this.settings.accountToken) { this.history.resetWith('/connect'); @@ -569,6 +575,7 @@ export default class AppRenderer { } private onDaemonDisconnected() { + this.connectedToDaemon = false; this.history.resetWith('/'); } @@ -674,19 +681,21 @@ export default class AppRenderer { } private handleAccountChange(oldAccount?: string, newAccount?: string) { - const reduxAccount = this.reduxActions.account; + if (this.connectedToDaemon) { + const reduxAccount = this.reduxActions.account; - if (oldAccount && !newAccount) { - if (this.loginTimer) { - clearTimeout(this.loginTimer); - } - reduxAccount.loggedOut(); - this.history.resetWith('/login'); - } else if (newAccount && oldAccount !== newAccount && !this.doingLogin) { - reduxAccount.updateAccountToken(newAccount); - reduxAccount.loggedIn(); - if (!oldAccount) { - this.history.resetWith('/connect'); + if (oldAccount && !newAccount) { + if (this.loginTimer) { + clearTimeout(this.loginTimer); + } + reduxAccount.loggedOut(); + this.history.resetWith('/login'); + } else if (newAccount && oldAccount !== newAccount && !this.doingLogin) { + reduxAccount.updateAccountToken(newAccount); + reduxAccount.loggedIn(); + if (!oldAccount) { + this.history.resetWith('/connect'); + } } } |
