From 2296ad69b9f96280b1585810e35cb58c53484d5c Mon Sep 17 00:00:00 2001 From: softsimon Date: Mon, 9 Mar 2020 17:53:54 +0700 Subject: [PATCH] Adding a third connection state and preventing offline indicator from pushing the menu. --- backend/src/api/websocket-handler.ts | 4 +-- .../components/address/address.component.ts | 4 +-- .../master-page/master-page.component.html | 6 +++- .../master-page/master-page.component.scss | 7 +++++ .../master-page/master-page.component.ts | 6 ++-- frontend/src/app/services/state.service.ts | 2 +- .../src/app/services/websocket.service.ts | 28 +++++++++++++------ 7 files changed, 40 insertions(+), 17 deletions(-) diff --git a/backend/src/api/websocket-handler.ts b/backend/src/api/websocket-handler.ts index c9a7f1789..400649b26 100644 --- a/backend/src/api/websocket-handler.ts +++ b/backend/src/api/websocket-handler.ts @@ -136,7 +136,7 @@ class WebsocketHandler { const foundTransactions: TransactionExtended[] = []; newTransactions.forEach((tx) => { - const someVin = tx.vin.some((vin) => vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']); + const someVin = tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address']); if (someVin) { foundTransactions.push(tx); return; @@ -185,7 +185,7 @@ class WebsocketHandler { const foundTransactions: TransactionExtended[] = []; transactions.forEach((tx) => { - if (tx.vin && tx.vin.some((vin) => vin.prevout && vin.prevout.scriptpubkey_address === client['track-address'])) { + if (tx.vin && tx.vin.some((vin) => !!vin.prevout && vin.prevout.scriptpubkey_address === client['track-address'])) { foundTransactions.push(tx); return; } diff --git a/frontend/src/app/components/address/address.component.ts b/frontend/src/app/components/address/address.component.ts index bedbe08ce..d0fa8a670 100644 --- a/frontend/src/app/components/address/address.component.ts +++ b/frontend/src/app/components/address/address.component.ts @@ -97,9 +97,9 @@ export class AddressComponent implements OnInit, OnDestroy { this.loadedConfirmedTxCount++; }); - this.stateService.isOffline$ + this.stateService.connectionState$ .subscribe((state) => { - if (!state && this.transactions && this.transactions.length) { + if (state === 2 && this.transactions && this.transactions.length) { this.loadAddress(this.addressString); } }); diff --git a/frontend/src/app/components/master-page/master-page.component.html b/frontend/src/app/components/master-page/master-page.component.html index 9fc75159f..8f9c1c132 100644 --- a/frontend/src/app/components/master-page/master-page.component.html +++ b/frontend/src/app/components/master-page/master-page.component.html @@ -1,6 +1,10 @@