Remove all lightning elements on unsupported networks
This commit is contained in:
		
							parent
							
								
									db34ca6a5f
								
							
						
					
					
						commit
						788caf05ce
					
				| @ -28,7 +28,7 @@ | |||||||
|     </div> |     </div> | ||||||
|   </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> |     <button class="btn btn-primary w-100" id="dropdownBasic1" ngbDropdownToggle i18n="lightning">Lightning</button> | ||||||
|     <div ngbDropdownMenu aria-labelledby="dropdownBasic1"> |     <div ngbDropdownMenu aria-labelledby="dropdownBasic1"> | ||||||
|       <a class="dropdown-item" routerLinkActive="active" [routerLink]="['/graphs/lightning/nodes-networks' | relativeUrl]" |       <a class="dropdown-item" routerLinkActive="active" [routerLink]="['/graphs/lightning/nodes-networks' | relativeUrl]" | ||||||
|  | |||||||
| @ -92,7 +92,7 @@ | |||||||
|       <li class="nav-item" routerLinkActive="active" [routerLinkActiveOptions]="{exact: true}" id="btn-pools" *ngIf="stateService.env.MINING_DASHBOARD"> |       <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> |         <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> | ||||||
|       <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 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> |         </a> | ||||||
|       </li> |       </li> | ||||||
|  | |||||||
| @ -27,7 +27,6 @@ export class MasterPageComponent implements OnInit, OnDestroy { | |||||||
|   subdomain = ''; |   subdomain = ''; | ||||||
|   networkPaths: { [network: string]: string }; |   networkPaths: { [network: string]: string }; | ||||||
|   networkPaths$: Observable<Record<string, string>>; |   networkPaths$: Observable<Record<string, string>>; | ||||||
|   lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet']; |  | ||||||
|   footerVisible = true; |   footerVisible = true; | ||||||
|   user: any = undefined; |   user: any = undefined; | ||||||
|   servicesEnabled = false; |   servicesEnabled = false; | ||||||
|  | |||||||
| @ -122,7 +122,7 @@ export class SearchFormComponent implements OnInit { | |||||||
|           ]); |           ]); | ||||||
|         } |         } | ||||||
|         this.isTypeaheading$.next(true); |         this.isTypeaheading$.next(true); | ||||||
|         if (!this.stateService.env.LIGHTNING) { |         if (!this.stateService.networkSupportsLightning()) { | ||||||
|           return zip( |           return zip( | ||||||
|             this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), |             this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), | ||||||
|             [{ nodes: [], channels: [] }], |             [{ nodes: [], channels: [] }], | ||||||
|  | |||||||
| @ -112,7 +112,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { | |||||||
|         ), |         ), | ||||||
|         this.refreshChannels$ |         this.refreshChannels$ | ||||||
|           .pipe( |           .pipe( | ||||||
|             filter(() => this.stateService.env.LIGHTNING), |             filter(() => this.stateService.networkSupportsLightning()), | ||||||
|             switchMap((txIds) => this.apiService.getChannelByTxIds$(txIds)), |             switchMap((txIds) => this.apiService.getChannelByTxIds$(txIds)), | ||||||
|             catchError((error) => { |             catchError((error) => { | ||||||
|               // handle 404
 |               // handle 404
 | ||||||
| @ -248,7 +248,7 @@ export class TransactionsListComponent implements OnInit, OnChanges { | |||||||
|       if (txIds.length && !this.cached) { |       if (txIds.length && !this.cached) { | ||||||
|         this.refreshOutspends$.next(txIds); |         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); |         const txIds = this.transactions.filter((tx) => !tx._channels).map((tx) => tx.txid); | ||||||
|         if (txIds.length) { |         if (txIds.length) { | ||||||
|           this.refreshChannels$.next(txIds); |           this.refreshChannels$.next(txIds); | ||||||
|  | |||||||
| @ -115,6 +115,7 @@ export class StateService { | |||||||
|   isMempoolSpaceBuild = window['isMempoolSpaceBuild'] ?? false; |   isMempoolSpaceBuild = window['isMempoolSpaceBuild'] ?? false; | ||||||
|   backend: 'esplora' | 'electrum' | 'none' = 'esplora'; |   backend: 'esplora' | 'electrum' | 'none' = 'esplora'; | ||||||
|   network = ''; |   network = ''; | ||||||
|  |   lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet']; | ||||||
|   lightning = false; |   lightning = false; | ||||||
|   blockVSize: number; |   blockVSize: number; | ||||||
|   env: Env; |   env: Env; | ||||||
| @ -370,6 +371,10 @@ export class StateService { | |||||||
|     this.lightningChanged$.next(this.lightning); |     this.lightningChanged$.next(this.lightning); | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|  |   networkSupportsLightning() { | ||||||
|  |     return this.env.LIGHTNING && this.lightningNetworks.includes(this.network); | ||||||
|  |   } | ||||||
|  | 
 | ||||||
|   getHiddenProp(){ |   getHiddenProp(){ | ||||||
|     const prefixes = ['webkit', 'moz', 'ms', 'o']; |     const prefixes = ['webkit', 'moz', 'ms', 'o']; | ||||||
|     if ('hidden' in document) { return 'hidden'; } |     if ('hidden' in document) { return 'hidden'; } | ||||||
|  | |||||||
| @ -58,7 +58,7 @@ | |||||||
|         <div class="links"> |         <div class="links"> | ||||||
|           <p class="category" i18n="footer.explore">Explore</p> |           <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.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]="['/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/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> |           <p><a [routerLink]="['/tx/test' | relativeUrl]" i18n="shared.test-transaction|Test Transaction">Test Transaction</a></p> | ||||||
|  | |||||||
| @ -28,7 +28,6 @@ export class GlobalFooterComponent implements OnInit, OnDestroy { | |||||||
|   network$: Observable<string>; |   network$: Observable<string>; | ||||||
|   networkPaths: { [network: string]: string }; |   networkPaths: { [network: string]: string }; | ||||||
|   currentNetwork = ''; |   currentNetwork = ''; | ||||||
|   lightningNetworks = ['', 'mainnet', 'bitcoin', 'testnet', 'signet']; |  | ||||||
|   loggedIn = false; |   loggedIn = false; | ||||||
|   urlSubscription: Subscription; |   urlSubscription: Subscription; | ||||||
|   isServicesPage = false; |   isServicesPage = false; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user