From 5d7324ced26c5027fa2d0e12a7545f6e11924323 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Tue, 15 Oct 2024 18:22:49 +0200 Subject: [PATCH] Optimize wifi check, disable dev tools --- app/main.ts | 7 +------ .../services/daemon/daemon-data.service.ts | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/main.ts b/app/main.ts index 4b876f6..4dbfa30 100644 --- a/app/main.ts +++ b/app/main.ts @@ -68,15 +68,12 @@ function createWindow(): BrowserWindow { preload: path.join(__dirname, 'preload.js'), nodeIntegration: false, allowRunningInsecureContent: (serve), - contextIsolation: true, - devTools: true, + contextIsolation: true }, autoHideMenuBar: true, icon: wdwIcon }); - //win.webContents.openDevTools(); - //win.setIcon() if (serve) { const debug = require('electron-debug'); @@ -139,14 +136,12 @@ function isWifiConnectedOld() { const networkInterfaces = os.networkInterfaces(); console.log(`isWifiConnected(): network interfaces ${networkInterfaces}`); - console.log(networkInterfaces); for (const interfaceName in networkInterfaces) { const networkInterface = networkInterfaces[interfaceName]; if (networkInterface) { for (const network of networkInterface) { - console.log(network); if (network.family === 'IPv4' && !network.internal && network.mac !== '00:00:00:00:00:00') { if (interfaceName.toLowerCase().includes('wifi') || interfaceName.toLowerCase().includes('wlan')) { return true; diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index f130388..584c840 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -337,17 +337,24 @@ export class DaemonDataService { } const syncAlreadyDisabled = this.daemonService.settings.noSync; - const wifiConnected = await this.daemonService.isWifiConnected(); - if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi && wifiConnected) { - console.log("Disabling sync ..."); + if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) { + const wifiConnected = await this.daemonService.isWifiConnected(); - await this.daemonService.disableSync(); + if (wifiConnected) { + console.log("Disabling sync ..."); + await this.daemonService.disableSync(); + } } - else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi && !wifiConnected) { - console.log("Enabling sync ..."); + else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) { + const wifiConnected = await this.daemonService.isWifiConnected(); + + if (!wifiConnected) { + console.log("Enabling sync ..."); + + await this.daemonService.enableSync(); + } - await this.daemonService.enableSync(); } this.syncStart.emit({ first: this._firstRefresh });