[Library|Trunk]
community service: keeps subscription is array, update clear method. Advanced search: add check for selected fields array git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60730 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
3df657b29a
commit
d856aadf61
|
@ -14,8 +14,7 @@ export class CommunityService {
|
|||
|
||||
public community: BehaviorSubject<CommunityInfo> = null;
|
||||
private promise: Promise<boolean> = null;
|
||||
private sub;
|
||||
|
||||
private subs=[];
|
||||
constructor(private http: HttpClient) {
|
||||
this.community = new BehaviorSubject(null);
|
||||
}
|
||||
|
@ -25,9 +24,11 @@ export class CommunityService {
|
|||
}
|
||||
|
||||
clearSubscriptions() {
|
||||
if (this.sub instanceof Subscriber) {
|
||||
this.sub.unsubscribe();
|
||||
}
|
||||
this.subs.forEach(subscription => {
|
||||
if (subscription instanceof Subscriber) {
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public getCommunityAsObservable() {
|
||||
|
@ -41,7 +42,7 @@ export class CommunityService {
|
|||
getCommunity(communityId: string, refresh = false) {
|
||||
if(!this.community.value || this.community.value.communityId !== communityId || refresh) {
|
||||
this.promise = new Promise<any>((resolve, reject) => {
|
||||
this.sub = this.http.get<CommunityInfo>(properties.communityAPI + communityId)
|
||||
this.subs.push(this.http.get<CommunityInfo>(properties.communityAPI + communityId)
|
||||
.pipe(map(community => this.parseCommunity(community))).subscribe(community => {
|
||||
this.community.next(community);
|
||||
resolve();
|
||||
|
@ -49,7 +50,7 @@ export class CommunityService {
|
|||
error => {
|
||||
this.community.next(null);
|
||||
resolve();
|
||||
})
|
||||
}));
|
||||
});
|
||||
}
|
||||
return from(this.getCommunityAsync());
|
||||
|
@ -57,7 +58,6 @@ export class CommunityService {
|
|||
|
||||
async getCommunityAsync() {
|
||||
await this.promise;
|
||||
this.clearSubscriptions();
|
||||
return this.community.getValue();
|
||||
}
|
||||
|
||||
|
|
|
@ -143,7 +143,7 @@
|
|||
[onChangeNavigate]="true" [customFilter]="customFilter"></entities-selection>
|
||||
</div>
|
||||
<div class="uk-padding-remove-left uk-margin-small-top">
|
||||
<div class="uk-inline">
|
||||
<div *ngIf="selectedFields[0]" class="uk-inline">
|
||||
<a *ngIf="selectedFields[0].value.length > 0" class="uk-form-icon uk-form-icon-flip"
|
||||
(click)="selectedFields[0].value = ''"
|
||||
uk-icon="icon: close"></a>
|
||||
|
|
Loading…
Reference in New Issue