From 788caf05ceee54c7734ddec5918ae41444c1fbed Mon Sep 17 00:00:00 2001 From: Mononaut Date: Sun, 12 May 2024 16:44:07 +0000 Subject: [PATCH] Remove all lightning elements on unsupported networks --- frontend/src/app/components/graphs/graphs.component.html | 2 +- .../app/components/master-page/master-page.component.html | 2 +- .../src/app/components/master-page/master-page.component.ts | 1 - .../src/app/components/search-form/search-form.component.ts | 2 +- .../transactions-list/transactions-list.component.ts | 4 ++-- frontend/src/app/services/state.service.ts | 5 +++++ .../components/global-footer/global-footer.component.html | 2 +- .../components/global-footer/global-footer.component.ts | 1 - 8 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/app/components/graphs/graphs.component.html b/frontend/src/app/components/graphs/graphs.component.html index 53d18bbc2..294d32c1e 100644 --- a/frontend/src/app/components/graphs/graphs.component.html +++ b/frontend/src/app/components/graphs/graphs.component.html @@ -28,7 +28,7 @@ -
+
- diff --git a/frontend/src/app/components/master-page/master-page.component.ts b/frontend/src/app/components/master-page/master-page.component.ts index fc10a9e44..f3472f204 100644 --- a/frontend/src/app/components/master-page/master-page.component.ts +++ b/frontend/src/app/components/master-page/master-page.component.ts @@ -27,7 +27,6 @@ export class MasterPageComponent implements OnInit, OnDestroy { subdomain = ''; networkPaths: { [network: string]: string }; networkPaths$: Observable>; - lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet']; footerVisible = true; user: any = undefined; servicesEnabled = false; diff --git a/frontend/src/app/components/search-form/search-form.component.ts b/frontend/src/app/components/search-form/search-form.component.ts index fe073564e..605dca962 100644 --- a/frontend/src/app/components/search-form/search-form.component.ts +++ b/frontend/src/app/components/search-form/search-form.component.ts @@ -122,7 +122,7 @@ export class SearchFormComponent implements OnInit { ]); } this.isTypeaheading$.next(true); - if (!this.stateService.env.LIGHTNING) { + if (!this.stateService.networkSupportsLightning()) { return zip( this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), [{ nodes: [], channels: [] }], diff --git a/frontend/src/app/components/transactions-list/transactions-list.component.ts b/frontend/src/app/components/transactions-list/transactions-list.component.ts index fc2afefc6..127f2dfe1 100644 --- a/frontend/src/app/components/transactions-list/transactions-list.component.ts +++ b/frontend/src/app/components/transactions-list/transactions-list.component.ts @@ -112,7 +112,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { ), this.refreshChannels$ .pipe( - filter(() => this.stateService.env.LIGHTNING), + filter(() => this.stateService.networkSupportsLightning()), switchMap((txIds) => this.apiService.getChannelByTxIds$(txIds)), catchError((error) => { // handle 404 @@ -248,7 +248,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { if (txIds.length && !this.cached) { this.refreshOutspends$.next(txIds); } - if (this.stateService.env.LIGHTNING) { + if (this.stateService.networkSupportsLightning()) { const txIds = this.transactions.filter((tx) => !tx._channels).map((tx) => tx.txid); if (txIds.length) { this.refreshChannels$.next(txIds); diff --git a/frontend/src/app/services/state.service.ts b/frontend/src/app/services/state.service.ts index 742ca7ab1..fe49a0aa4 100644 --- a/frontend/src/app/services/state.service.ts +++ b/frontend/src/app/services/state.service.ts @@ -115,6 +115,7 @@ export class StateService { isMempoolSpaceBuild = window['isMempoolSpaceBuild'] ?? false; backend: 'esplora' | 'electrum' | 'none' = 'esplora'; network = ''; + lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet']; lightning = false; blockVSize: number; env: Env; @@ -370,6 +371,10 @@ export class StateService { this.lightningChanged$.next(this.lightning); } + networkSupportsLightning() { + return this.env.LIGHTNING && this.lightningNetworks.includes(this.network); + } + getHiddenProp(){ const prefixes = ['webkit', 'moz', 'ms', 'o']; if ('hidden' in document) { return 'hidden'; } diff --git a/frontend/src/app/shared/components/global-footer/global-footer.component.html b/frontend/src/app/shared/components/global-footer/global-footer.component.html index 9193a8b32..ffb0e313e 100644 --- a/frontend/src/app/shared/components/global-footer/global-footer.component.html +++ b/frontend/src/app/shared/components/global-footer/global-footer.component.html @@ -58,7 +58,7 @@