Search result fix when Lightning not enabled

This commit is contained in:
softsimon 2022-07-06 16:21:14 +02:00
parent 850060cc07
commit 1f2254681a
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7
3 changed files with 9 additions and 2 deletions

View File

@ -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(
this.electrsApiService.getAddressesByPrefix$(text).pipe(catchError(() => of([]))),
this.apiService.lightningSearch$(text).pipe(catchError(() => of({

View File

@ -1,6 +1,6 @@
<div class="dropdown-menu show" *ngIf="results" [hidden]="!results.addresses.length && !results.nodes.length && !results.channels.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">
<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>

View File

@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
import { StateService } from 'src/app/services/state.service';
@Component({
selector: 'app-search-results',
@ -15,7 +16,7 @@ export class SearchResultsComponent implements OnChanges {
activeIdx = 0;
focusFirst = true;
constructor() { }
constructor(public stateService: StateService) { }
ngOnChanges() {
this.activeIdx = 0;