Search result fix when Lightning not enabled
This commit is contained in:
		
							parent
							
								
									850060cc07
								
							
						
					
					
						commit
						1f2254681a
					
				| @ -80,6 +80,12 @@ export class SearchFormComponent implements OnInit { | |||||||
|               } |               } | ||||||
|             ]); |             ]); | ||||||
|           } |           } | ||||||
|  |           if (!this.stateService.env.LIGHTNING) { | ||||||
|  |             return zip( | ||||||
|  |               this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), | ||||||
|  |               [{ nodes: [], channels: [] }] | ||||||
|  |             ); | ||||||
|  |           } | ||||||
|           return zip( |           return zip( | ||||||
|             this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), |             this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))), | ||||||
|             this.apiService.lightningSearch$(text).pipe(catchError(() => of({ |             this.apiService.lightningSearch$(text).pipe(catchError(() => of({ | ||||||
|  | |||||||
| @ -1,6 +1,6 @@ | |||||||
| <div class="dropdown-menu show" *ngIf="results" [hidden]="!results.addresses.length && !results.nodes.length && !results.channels.length"> | <div class="dropdown-menu show" *ngIf="results" [hidden]="!results.addresses.length && !results.nodes.length && !results.channels.length"> | ||||||
|   <ng-template [ngIf]="results.addresses.length"> |   <ng-template [ngIf]="results.addresses.length"> | ||||||
|     <div class="card-title">Bitcoin Addresses</div> |     <div class="card-title" *ngIf="stateService.env.LIGHTNING">Bitcoin Addresses</div> | ||||||
|     <ng-template ngFor [ngForOf]="results.addresses" let-address let-i="index"> |     <ng-template ngFor [ngForOf]="results.addresses" let-address let-i="index"> | ||||||
|       <button (click)="clickItem(i)" [class.active]="i === activeIdx" type="button" role="option" class="dropdown-item"> |       <button (click)="clickItem(i)" [class.active]="i === activeIdx" type="button" role="option" class="dropdown-item"> | ||||||
|         <ngb-highlight [result]="address | shortenString : isMobile ? 25 : 36" [term]="searchTerm"></ngb-highlight> |         <ngb-highlight [result]="address | shortenString : isMobile ? 25 : 36" [term]="searchTerm"></ngb-highlight> | ||||||
|  | |||||||
| @ -1,4 +1,5 @@ | |||||||
| import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; | import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; | ||||||
|  | import { StateService } from 'src/app/services/state.service'; | ||||||
| 
 | 
 | ||||||
| @Component({ | @Component({ | ||||||
|   selector: 'app-search-results', |   selector: 'app-search-results', | ||||||
| @ -15,7 +16,7 @@ export class SearchResultsComponent implements OnChanges { | |||||||
|   activeIdx = 0; |   activeIdx = 0; | ||||||
|   focusFirst = true; |   focusFirst = true; | ||||||
| 
 | 
 | ||||||
|   constructor() { } |   constructor(public stateService: StateService) { } | ||||||
| 
 | 
 | ||||||
|   ngOnChanges() { |   ngOnChanges() { | ||||||
|     this.activeIdx = 0; |     this.activeIdx = 0; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user