From d0ee07e1adf7a584a00c37eae1ea0c34ef148488 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Tue, 9 Jan 2024 17:41:20 +0200 Subject: [PATCH] [master | DONE | FIXED]: Fixed when showLoading is set to false - either when search requests are finished or when there are no results. --- .../browse-repositories.component.ts | 50 ++++++++++--------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/app/repository/browse-repositories/browse-repositories.component.ts b/src/app/repository/browse-repositories/browse-repositories.component.ts index 94ccce5..7c54350 100644 --- a/src/app/repository/browse-repositories/browse-repositories.component.ts +++ b/src/app/repository/browse-repositories/browse-repositories.component.ts @@ -62,29 +62,33 @@ export class BrowseRepositoriesComponent extends BrowseStakeholderBaseComponent afterStakeholdersInitialized() { let currentFilteredStakeholders = this.filteredStakeholders.slice((this.currentPage-1)*this.pageSize, this.currentPage*this.pageSize); - let obs: Observable[] = []; - currentFilteredStakeholders.forEach(item => { - if(!item.details) { - this.showLoading = true; - let ob = this.searchDataprovidersService.searchDataproviderById(item.index_id).pipe( - catchError(error => { - let details: SearchResult = new SearchResult(); - details['title'] = {'name': item.name, 'accessMode': ''}; - details['entityType'] = "dataprovider"; - return of([details]); - })); - obs.push(ob); - } - }); - this.subscriptions.push(forkJoin(obs).subscribe( - data => { - data.forEach((item, index) => { - currentFilteredStakeholders[index].details = item[0]; - currentFilteredStakeholders[index].details['title']['name'] = currentFilteredStakeholders[index].name; - }); - } - )); - this.showLoading = false; + if(currentFilteredStakeholders && currentFilteredStakeholders.length > 0) { + let obs: Observable[] = []; + currentFilteredStakeholders.forEach(item => { + if (!item.details) { + this.showLoading = true; + let ob = this.searchDataprovidersService.searchDataproviderById(item.index_id).pipe( + catchError(error => { + let details: SearchResult = new SearchResult(); + details['title'] = {'name': item.name, 'accessMode': ''}; + details['entityType'] = "dataprovider"; + return of([details]); + })); + obs.push(ob); + } + }); + this.subscriptions.push(forkJoin(obs).subscribe( + data => { + data.forEach((item, index) => { + currentFilteredStakeholders[index].details = item[0]; + currentFilteredStakeholders[index].details['title']['name'] = currentFilteredStakeholders[index].name; + }); + this.showLoading = false; + } + )); + } else { + this.showLoading = false; + } } public getResultPreview(result: SearchResult): ResultPreview {