diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 4697bd4..2e69588 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -74,7 +74,6 @@ export class AppComponent { var community = null; this.community = null; this.showMenu = false; - this._communitiesService.getCommunities(this.properties, this.properties.communitiesAPI).subscribe ( communities => { @@ -95,7 +94,7 @@ export class AppComponent { this.managerOfCommunities = true; }else if(com.managers.indexOf(Session.getUserEmail())!=-1){ this.managerOfCommunities = true; - }else if(!this.subscriberOfCommunities){ + }/*else if(!this.subscriberOfCommunities){ // check if subscriber this._subscribeService.isSubscribedToCommunity(com.communityId, Session.getUserEmail(), this.properties.adminToolsAPIURL).subscribe ( isSubscriber => { @@ -107,7 +106,7 @@ export class AppComponent { console.error("Error fetching your subscribed communities") }); - } + }*/ } diff --git a/src/app/searchPages/communities/searchCommunities.component.ts b/src/app/searchPages/communities/searchCommunities.component.ts index 368d649..9a8a3e5 100644 --- a/src/app/searchPages/communities/searchCommunities.component.ts +++ b/src/app/searchPages/communities/searchCommunities.component.ts @@ -107,32 +107,40 @@ export class SearchCommunitiesComponent { let observables: Observable[] = []; for(let i = 0; i < data.length; i++) { this.totalResults[i] = data[i]; + this.totalResults[i].isManager = false; + this.totalResults[i].isSubscribed = false; // For Test do not delete them. //this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation." //this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime())); - let observable: Observable = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]); - observables.push(observable.pipe(catchError(err => { - return of(false); - }))); - this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]); + if(Session.isLoggedIn()) { + let observable: Observable = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]); + observables.push(observable.pipe(catchError(err => { + return of(false); + }))); + this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]); + } } - Observable.forkJoin(observables).subscribe( - res => { - for(let i = 0; i < res.length; i++) { - this.totalResults[i].isSubscribed = res[i]; + if (observables.length > 0) { + Observable.forkJoin(observables).subscribe( + res => { + for (let i = 0; i < res.length; i++) { + this.totalResults[i].isSubscribed = res[i]; + } + this._getResults(params); } - this._getResults(params); - } - ); + ); + } + else { + this._getResults(params); + } }, err => { - //console.log(err); this.handleError('Error getting communities', err); this.searchUtils.status = this.errorMessages.getErrorCode(err.status); this.disableForms = false; this.scroll(); } - ); + ); }