Search Communities: Fix a bug with parsing results
This commit is contained in:
parent
69b4d10384
commit
4fd401297c
|
@ -117,6 +117,14 @@ export class SearchCommunitiesComponent {
|
|||
});
|
||||
}
|
||||
|
||||
private parseResults(data: any) {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.totalResults[i] = data[i];
|
||||
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
||||
this.totalResults[i].isSubscribed = Session.isSubscribedTo('community', this.totalResults[i].communityId, this.user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize communities from Communities APIs
|
||||
*
|
||||
|
@ -124,19 +132,13 @@ export class SearchCommunitiesComponent {
|
|||
*/
|
||||
private initCommunities(params) {
|
||||
if(this.totalResults) {
|
||||
this.parseResults(this.totalResults);
|
||||
this._getResults(params);
|
||||
} else {
|
||||
this.totalResults = [];
|
||||
this.subscriptions.push(this._communitiesService.getCommunitiesState().subscribe(
|
||||
data => {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
this.totalResults[i] = data[i];
|
||||
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
|
||||
this.totalResults[i].isSubscribed = Session.isSubscribedTo('community', this.totalResults[i].communityId, this.user);
|
||||
}
|
||||
this.totalResults = [];
|
||||
this.parseResults(data);
|
||||
this._getResults(params);
|
||||
},
|
||||
err => {
|
||||
|
|
Loading…
Reference in New Issue