From 09782e68f7942be06dd70669b6c398b8cd4b82ff Mon Sep 17 00:00:00 2001 From: everoddandeven Date: Fri, 1 Nov 2024 09:28:08 +0100 Subject: [PATCH] Minor fixes --- .../services/daemon/daemon-data.service.ts | 102 +++++++++--------- .../core/services/daemon/daemon.service.ts | 11 +- src/app/pages/network/network.component.html | 26 ++--- .../transactions/transactions.component.html | 14 +-- 4 files changed, 75 insertions(+), 78 deletions(-) diff --git a/src/app/core/services/daemon/daemon-data.service.ts b/src/app/core/services/daemon/daemon-data.service.ts index 01dbafb..f749f09 100644 --- a/src/app/core/services/daemon/daemon-data.service.ts +++ b/src/app/core/services/daemon/daemon-data.service.ts @@ -69,7 +69,7 @@ export class DaemonDataService { public readonly syncStart: EventEmitter<{ first: boolean }> = new EventEmitter<{ first: boolean }>(); public readonly syncEnd: EventEmitter = new EventEmitter(); - public readonly syncError: EventEmitter = new EventEmitter(); + public readonly syncError: EventEmitter = new EventEmitter(); public readonly syncInfoRefreshStart: EventEmitter = new EventEmitter(); public readonly syncInfoRefreshEnd: EventEmitter = new EventEmitter(); @@ -354,58 +354,64 @@ export class DaemonDataService { this._refreshing = true; - const settings = await this.daemonService.getSettings(); + try { + const settings = await this.daemonService.getSettings(); - const updateInfo = await this.daemonService.checkUpdate() - - if (updateInfo.update) { - await this.daemonService.upgrade(); - return; - } - - const syncAlreadyDisabled = this.daemonService.settings.noSync; - - if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) { - const wifiConnected = await this.electronService.isWifiConnected(); - - if (wifiConnected) { - console.log("Disabling sync ..."); - await this.daemonService.disableSync(); - this.syncDisabledByWifiPolicy = true; + const updateInfo = await this.daemonService.checkUpdate() + + if (updateInfo.update && settings.upgradeAutomatically) { + await this.daemonService.upgrade(); + return; } - } - else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) { - const wifiConnected = await this.electronService.isWifiConnected(); - - if (!wifiConnected) { - console.log("Enabling sync ..."); - - await this.daemonService.enableSync(); - this.syncDisabledByWifiPolicy = false; + + const syncAlreadyDisabled = this.daemonService.settings.noSync; + + if (!settings.noSync && !syncAlreadyDisabled && !settings.syncOnWifi) { + const wifiConnected = await this.electronService.isWifiConnected(); + + if (wifiConnected) { + console.log("Disabling sync ..."); + await this.daemonService.disableSync(); + this.syncDisabledByWifiPolicy = true; + } + } + else if (!settings.noSync && syncAlreadyDisabled && !settings.syncOnWifi) { + const wifiConnected = await this.electronService.isWifiConnected(); + + if (!wifiConnected) { + console.log("Enabling sync ..."); + + await this.daemonService.enableSync(); + this.syncDisabledByWifiPolicy = false; + } + else { + this.syncDisabledByWifiPolicy = true; + } } else { - this.syncDisabledByWifiPolicy = true; + this.syncDisabledByWifiPolicy = false; } + + if (!syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && !this.syncDisabledByPeriodPolicy && settings.syncPeriodEnabled && !TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { + await this.daemonService.disableSync(); + this.syncDisabledByPeriodPolicy = true; + } + else if (syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && this.syncDisabledByPeriodPolicy && settings.syncPeriodEnabled && TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { + await this.daemonService.enableSync(); + this.syncDisabledByPeriodPolicy = false; + } + else if (syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && settings.syncPeriodEnabled && !TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { + this.syncDisabledByPeriodPolicy = true; + } + else { + this.syncDisabledByPeriodPolicy = false; + } + } - else { - this.syncDisabledByWifiPolicy = false; + catch(error: any) { + console.error(error); } - - if (!syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && !this.syncDisabledByPeriodPolicy && settings.syncPeriodEnabled && !TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { - await this.daemonService.disableSync(); - this.syncDisabledByPeriodPolicy = true; - } - else if (syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && this.syncDisabledByPeriodPolicy && settings.syncPeriodEnabled && TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { - await this.daemonService.enableSync(); - this.syncDisabledByPeriodPolicy = false; - } - else if (syncAlreadyDisabled && !this.syncDisabledByWifiPolicy && settings.syncPeriodEnabled && !TimeUtils.isInTimeRange(settings.syncPeriodFrom, settings.syncPeriodTo)) { - this.syncDisabledByPeriodPolicy = true; - } - else { - this.syncDisabledByPeriodPolicy = false; - } - + this.syncStart.emit({ first: this._firstRefresh }); try { @@ -507,7 +513,7 @@ export class DaemonDataService { this._lastRefreshHeight = this._daemonInfo.heightWithoutBootstrap; this._lastRefresh = Date.now(); - } catch(error) { + } catch(error: any) { console.error(error); this._gettingDaemonInfo = false; this._gettingSyncInfo = false; @@ -522,7 +528,7 @@ export class DaemonDataService { this._gettingPeerList = false; this._gettingTxPoolStats = false; - this.syncError.emit(error); + this.syncError.emit(error); if (!await this.daemonService.isRunning()) { this.stopLoop(); diff --git a/src/app/core/services/daemon/daemon.service.ts b/src/app/core/services/daemon/daemon.service.ts index 6cdc6d8..a1ae6a9 100644 --- a/src/app/core/services/daemon/daemon.service.ts +++ b/src/app/core/services/daemon/daemon.service.ts @@ -348,16 +348,7 @@ export class DaemonService { } catch (error: any) { if (error instanceof HttpErrorResponse) { - if (error.status == 0) { - const wasRunning = this.daemonRunning; - this.daemonRunning = false; - - if (wasRunning) { - this.onDaemonStatusChanged.emit(false); - } - } - - const errorMessage: string = `${error.message}`; + const errorMessage: string = error.status == 0 ? `No connection` : `${error.message}`; throw new Error(errorMessage); } diff --git a/src/app/pages/network/network.component.html b/src/app/pages/network/network.component.html index 21adecd..89202e5 100644 --- a/src/app/pages/network/network.component.html +++ b/src/app/pages/network/network.component.html @@ -36,25 +36,25 @@ > - ID - Peer ID + ID + Peer ID Address - Host - IP - Port + Host + IP + Port State - Avg Download - Avg Upload + Avg Download + Avg Upload Current Download Current Upload - Height + Height Incoming Live Time - Recv Count - Recv Idle Time - Send Count - Send Idle Time - Support Flags + Recv Count + Recv Idle Time + Send Count + Send Idle Time + Support Flags diff --git a/src/app/pages/transactions/transactions.component.html b/src/app/pages/transactions/transactions.component.html index e38908b..52ca1e1 100644 --- a/src/app/pages/transactions/transactions.component.html +++ b/src/app/pages/transactions/transactions.component.html @@ -76,17 +76,17 @@ ID Hash Relayed Blob Size - Do Not Relay + Do Not Relay Double Spend Seen Fee - Kept By Block - Last Failed Height - Last Failed Id Hash + Kept By Block + Last Failed Height + Last Failed Id Hash Last Relayed Time - Max Used Block Height - Max Used Block Id Hash + Max Used Block Height + Max Used Block Id Hash Receive Time - Tx Blob + Tx Blob