From 3333beec5e509c0204e84a747d74bdaab6c8d795 Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Tue, 12 Nov 2024 00:26:17 +0100 Subject: [PATCH] Minor fixes --- app/main.ts | 34 +++++++++++-------- .../services/daemon/daemon-data.service.ts | 7 +++- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/main.ts b/app/main.ts index 755962e..4b81be8 100644 --- a/app/main.ts +++ b/app/main.ts @@ -306,22 +306,28 @@ const createSplashWindow = async (): Promise => { // #region WiFi function isConnectedToWiFi(): Promise { - return new Promise((resolve, reject) => { - network.get_active_interface((err: any | null, obj: { name: string, ip_address: string, mac_address: string, type: string, netmask: string, gateway_ip: string }) => { - if (err) { - console.error("Errore durante il controllo della connessione Wi-Fi:", err); - reject(err); - } - else { - console.log('isConnectedToWifi:'); - console.log(obj); - resolve(obj.type == 'Wireless'); - } - }) - }); + try { + + return new Promise((resolve, reject) => { + network.get_active_interface((err: any | null, obj: { name: string, ip_address: string, mac_address: string, type: string, netmask: string, gateway_ip: string }) => { + if (err) { + console.error("Errore durante il controllo della connessione Wi-Fi:", err); + reject(err); + } + else { + console.log('isConnectedToWifi:'); + console.log(obj); + resolve(obj.type == 'Wireless'); + } + }) + }); + } + catch(error: any) { + return isConnectedToWiFiV2(); + } } -function isConnectedToWiFiOld(): Promise { +function isConnectedToWiFiV2(): Promise { return new Promise((resolve, reject) => { const platform = os.platform(); // Use os to get the platform diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index a612401..7c519b4 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -330,13 +330,18 @@ export class DaemonDataService { public syncDisabledByWifiPolicy: boolean = false; public syncDisabledByPeriodPolicy: boolean = false; + private osType?: { platform: string }; private async refresh(): Promise { if (this.refreshing || this.tooEarlyForRefresh || this.daemonService.stopping) { return; } - if (this._runningOnBattery === undefined) { + if (this.osType === undefined) { + this.osType = await this.electronService.getOsType(); + } + + if (this._runningOnBattery === undefined || this.osType.platform == 'linux') { this._runningOnBattery = await this.electronService.isOnBatteryPower(); }