64503: Fetch harvester endpoint using halService + small unsubscribe fix

This commit is contained in:
Kristof De Langhe
2019-09-03 11:19:23 +02:00
parent ff2083941a
commit 7432297dce
3 changed files with 7 additions and 5 deletions

View File

@@ -421,6 +421,8 @@ export class CollectionSourceComponent extends AbstractTrackableComponent implem
* Make sure open subscriptions are closed
*/
ngOnDestroy(): void {
if (this.updateSub) {
this.updateSub.unsubscribe();
}
}
}

View File

@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { filter, map, take, tap } from 'rxjs/operators';
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
import { Store } from '@ngrx/store';
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service';
@@ -80,7 +80,7 @@ export class CollectionDataService extends ComColDataService<Collection> {
*/
getHarvesterEndpoint(collectionId: string): Observable<string> {
return this.halService.getEndpoint(this.linkPath).pipe(
map((href: string) => `${href}/${collectionId}/harvester`)
switchMap((href: string) => this.halService.getEndpoint('harvester', `${href}/${collectionId}`))
);
}

View File

@@ -43,8 +43,8 @@ export class HALEndpointService {
);
}
public getEndpoint(linkPath: string): Observable<string> {
return this.getEndpointAt(this.getRootHref(), ...linkPath.split('/'));
public getEndpoint(linkPath: string, startHref?: string): Observable<string> {
return this.getEndpointAt(startHref || this.getRootHref(), ...linkPath.split('/'));
}
/**