[CSTPER-66] moved refreshCache function to common ComColDataService, tests have been moved accordingly.

Used HalEndpointService to discover communities search top endpoint
This commit is contained in:
Corrado Lombardi
2020-11-17 09:29:01 +01:00
parent 9658da4fc0
commit c40f31279f
6 changed files with 125 additions and 191 deletions

View File

@@ -101,7 +101,7 @@ export class CreateComColPageComponent<TDomain extends DSpaceObject> implements
} else {
this.navigateToNewPage();
}
this.refreshCache(dsoRD);
this.dsoDataService.refreshCache(dsoRD);
}
this.notificationsService.success(null, this.translate.get(this.type.value + '.create.notifications.success'));
});
@@ -115,23 +115,4 @@ export class CreateComColPageComponent<TDomain extends DSpaceObject> implements
this.router.navigate([this.frontendURL + this.newUUID]);
}
}
private refreshCache(dso: TDomain) {
const parentCommunityUrl = this.parentCommunityUrl(dso as any);
if (!hasValue(parentCommunityUrl)) {
return;
}
this.dsoDataService.findByHref(parentCommunityUrl).pipe(
getSucceededOrNoContentResponse(),
take(1),
).subscribe((rd: RemoteData<TDomain>) => {
const href = rd.hasSucceeded && !isEmpty(rd.payload.id) ? rd.payload.id : 'communities/search/top';
this.requestService.removeByHrefSubstring(href)
});
}
private parentCommunityUrl(dso: Collection | Community) {
const parentCommunity = dso._links.parentCommunity;
return isNotEmpty(parentCommunity) ? parentCommunity.href : null;
}
}