Remove all lightning elements on unsupported networks

This commit is contained in:
Mononaut
2024-05-12 16:44:07 +00:00
parent db34ca6a5f
commit 788caf05ce
8 changed files with 11 additions and 8 deletions

View File

@@ -28,7 +28,7 @@
</div>
</div>
<div ngbDropdown class="w-33" *ngIf="stateService.env.LIGHTNING">
<div ngbDropdown class="w-33" *ngIf="stateService.networkSupportsLightning()">
<button class="btn btn-primary w-100" id="dropdownBasic1" ngbDropdownToggle i18n="lightning">Lightning</button>
<div ngbDropdownMenu aria-labelledby="dropdownBasic1">
<a class="dropdown-item" routerLinkActive="active" [routerLink]="['/graphs/lightning/nodes-networks' | relativeUrl]"

View File

@@ -92,7 +92,7 @@
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" id="btn-pools" *ngIf="stateService.env.MINING_DASHBOARD">
<a class="nav-link" [routerLink]="['/mining' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'hammer']" [fixedWidth]="true" i18n-title="mining.mining-dashboard" title="Mining Dashboard"></fa-icon></a>
</li>
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" id="btn-lightning" *ngIf="stateService.env.LIGHTNING && lightningNetworks.includes(stateService.network)">
<li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" id="btn-lightning" *ngIf="stateService.networkSupportsLightning()">
<a class="nav-link" [routerLink]="['/lightning' | relativeUrl]" (click)="collapse()"><fa-icon [icon]="['fas', 'bolt']" [fixedWidth]="true" i18n-title="master-page.lightning" title="Lightning Explorer"></fa-icon>
</a>
</li>

View File

@@ -27,7 +27,6 @@ export class MasterPageComponent implements OnInit, OnDestroy {
subdomain = '';
networkPaths: { [network: string]: string };
networkPaths$: Observable<Record<string, string>>;
lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet'];
footerVisible = true;
user: any = undefined;
servicesEnabled = false;

View File

@@ -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: [] }],

View File

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