summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/main/index.ts31
-rw-r--r--gui/src/renderer/app.tsx28
2 files changed, 26 insertions, 33 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');
}
}
diff --git a/gui/src/renderer/app.tsx b/gui/src/renderer/app.tsx
index 54f843a6e0..5cb32d3517 100644
--- a/gui/src/renderer/app.tsx
+++ b/gui/src/renderer/app.tsx
@@ -121,7 +121,6 @@ export default class AppRenderer {
private tunnelState!: TunnelState;
private settings!: ISettings;
private guiSettings!: IGuiSettingsState;
- private autoConnected = false;
private doingLogin = false;
private loginScheduler = new Scheduler();
private connectedToDaemon = false;
@@ -646,9 +645,8 @@ export default class AppRenderer {
}
}
- private async onDaemonConnected() {
+ private onDaemonConnected() {
this.connectedToDaemon = true;
- await this.autoConnect();
this.resetNavigation();
}
@@ -698,30 +696,6 @@ export default class AppRenderer {
}
}
- private async autoConnect() {
- if (window.env.development) {
- log.info('Skip autoconnect in development');
- } else if (this.autoConnected) {
- log.info('Skip autoconnect because it was done before');
- } else if (this.settings.accountToken) {
- if (this.guiSettings.autoConnect) {
- try {
- log.info('Autoconnect the tunnel');
-
- await this.connectTunnel();
-
- this.autoConnected = true;
- } 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');
- }
- }
-
private setAccountHistory(accountHistory?: AccountToken) {
this.reduxActions.account.updateAccountHistory(accountHistory);
}