Merge pull request #5066 from mempool/mononaut/hide-t4-ln-graphs

Remove all lightning elements on unsupported networks
This commit is contained in:
wiz 2024-05-18 07:19:35 +09:00 committed by GitHub
commit 0497c750be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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);

View File

@ -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'; }

View File

@ -58,7 +58,7 @@
<div class="links">
<p class="category" i18n="footer.explore">Explore</p>
<p><a *ngIf="env.MINING_DASHBOARD" [routerLink]="['/mining' | relativeUrl]" i18n="mining.mining-dashboard">Mining Dashboard</a></p>
<p><a *ngIf="env.LIGHTNING && lightningNetworks.includes(stateService.network)" [routerLink]="['/lightning' | relativeUrl]" i18n="master-page.lightning">Lightning Explorer</a></p>
<p><a *ngIf="stateService.networkSupportsLightning()" [routerLink]="['/lightning' | relativeUrl]" i18n="master-page.lightning">Lightning Explorer</a></p>
<p><a [routerLink]="['/blocks' | relativeUrl]" i18n="dashboard.recent-blocks">Recent Blocks</a></p>
<p><a [routerLink]="['/tx/push' | relativeUrl]" i18n="shared.broadcast-transaction|Broadcast Transaction">Broadcast Transaction</a></p>
<p><a [routerLink]="['/tx/test' | relativeUrl]" i18n="shared.test-transaction|Test Transaction">Test Transaction</a></p>

View File

@ -28,7 +28,6 @@ export class GlobalFooterComponent implements OnInit, OnDestroy {
network$: Observable<string>;
networkPaths: { [network: string]: string };
currentNetwork = '';
lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet'];
loggedIn = false;
urlSubscription: Subscription;
isServicesPage = false;