Handle and don't crash for adress-prefix search error.

fixes #121
This commit is contained in:
softsimon 2020-10-12 12:57:19 +07:00
parent f5e270c770
commit 55646b5732
No known key found for this signature in database
GPG Key ID: 488D7DCFB5A430D7

View File

@ -4,7 +4,7 @@ import { Router } from '@angular/router';
import { AssetsService } from 'src/app/services/assets.service';
import { StateService } from 'src/app/services/state.service';
import { Observable, of, Subject, merge } from 'rxjs';
import { debounceTime, distinctUntilChanged, switchMap, filter } from 'rxjs/operators';
import { debounceTime, distinctUntilChanged, switchMap, filter, catchError } from 'rxjs/operators';
import { ElectrsApiService } from 'src/app/services/electrs-api.service';
import { NgbTypeahead } from '@ng-bootstrap/ng-bootstrap';
@ -39,7 +39,8 @@ export class SearchFormComponent implements OnInit {
.pipe(
switchMap((text) => {
if (!text.length) { return of([]); }
return this.electrsApiService.getAddressesByPrefix$(text);
return this.electrsApiService.getAddressesByPrefix$(text)
.pipe(catchError(() => of([])));
})
);
}