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'),
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;

View file

@ -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 });