Commit ced6e391 authored by Thibault Ehrhart's avatar Thibault Ehrhart

Cancel current search before starting a new one

parent f6af262d
......@@ -27,6 +27,7 @@ export class HomeComponent implements OnInit {
isLoading: boolean = true;
isFullscreen: boolean = false;
inDetailsView: boolean = false;
subSearch: any;
subjectCodes: NgOption[] = [];
locations: NgOption[] = [];
......@@ -265,9 +266,12 @@ export class HomeComponent implements OnInit {
}
doSearch() {
if (this.subSearch) {
this.subSearch.unsubscribe();
}
this.news.length = 0;
this.isLoading = true;
this.newsService.getNews(this.search.searchParams)
this.subSearch = this.newsService.getNews(this.search.searchParams)
.pipe(finalize(() => { this.isLoading = false; }))
.subscribe((data: any) => {
this.news = data.results.bindings;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment