Optimize wifi check, disable dev tools

This commit is contained in:
everoddandeven 2024-10-15 18:22:49 +02:00
parent ab0c54c458
commit 5d7324ced2
2 changed files with 15 additions and 13 deletions

View file

@ -68,15 +68,12 @@ function createWindow(): BrowserWindow {
preload: path.join(__dirname, 'preload.js'), preload: path.join(__dirname, 'preload.js'),
nodeIntegration: false, nodeIntegration: false,
allowRunningInsecureContent: (serve), allowRunningInsecureContent: (serve),
contextIsolation: true, contextIsolation: true
devTools: true,
}, },
autoHideMenuBar: true, autoHideMenuBar: true,
icon: wdwIcon icon: wdwIcon
}); });
//win.webContents.openDevTools();
//win.setIcon()
if (serve) { if (serve) {
const debug = require('electron-debug'); const debug = require('electron-debug');
@ -139,14 +136,12 @@ function isWifiConnectedOld() {
const networkInterfaces = os.networkInterfaces(); const networkInterfaces = os.networkInterfaces();
console.log(`isWifiConnected(): network interfaces ${networkInterfaces}`); console.log(`isWifiConnected(): network interfaces ${networkInterfaces}`);
console.log(networkInterfaces);
for (const interfaceName in networkInterfaces) { for (const interfaceName in networkInterfaces) {
const networkInterface = networkInterfaces[interfaceName]; const networkInterface = networkInterfaces[interfaceName];
if (networkInterface) { if (networkInterface) {
for (const network of networkInterface) { for (const network of networkInterface) {
console.log(network);
if (network.family === 'IPv4' && !network.internal && network.mac !== '00:00:00:00:00:00') { if (network.family === 'IPv4' && !network.internal && network.mac !== '00:00:00:00:00:00') {
if (interfaceName.toLowerCase().includes('wifi') || interfaceName.toLowerCase().includes('wlan')) { if (interfaceName.toLowerCase().includes('wifi') || interfaceName.toLowerCase().includes('wlan')) {
return true; return true;

View file

@ -337,17 +337,24 @@ export class DaemonDataService {
} }
const syncAlreadyDisabled = this.daemonService.settings.noSync; const syncAlreadyDisabled = this.daemonService.settings.noSync;
const wifiConnected = await this.daemonService.isWifiConnected();
if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi && wifiConnected) { if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) {
console.log("Disabling sync ..."); 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) { else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) {
console.log("Enabling sync ..."); 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 }); this.syncStart.emit({ first: this._firstRefresh });