[DURACOM-350] prevent unnecessary reload

This commit is contained in:
FrancescoMolinaro
2025-04-23 15:47:01 +02:00
parent e84af6ab91
commit 1b112dd887

View File

@@ -107,15 +107,19 @@ export abstract class MyDSpaceActionsComponent<T extends DSpaceObject, TService
};
// This assures that the search cache is empty before reloading mydspace.
// See https://github.com/DSpace/dspace-angular/pull/468
this.invalidateCacheForCurrentSearchUrl();
this.invalidateCacheForCurrentSearchUrl(true);
}
invalidateCacheForCurrentSearchUrl(): void {
invalidateCacheForCurrentSearchUrl(shouldNavigate = false): void {
const url = decodeURIComponent(this.router.url);
this.searchService.getEndpoint().pipe(
take(1),
tap((cachedHref: string) => this.requestService.removeByHrefSubstring(cachedHref)),
).subscribe(() => this.router.navigateByUrl(url));
).subscribe(() => {
if (shouldNavigate) {
this.router.navigateByUrl(url);
}
});
}
/**