[DURACOM-350] prevent unnecessary reload

(cherry picked from commit 1b112dd887)
This commit is contained in:
FrancescoMolinaro
2025-04-23 15:47:01 +02:00
committed by github-actions[bot]
parent 44f46a9a8a
commit 67d71e6da4

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. // This assures that the search cache is empty before reloading mydspace.
// See https://github.com/DSpace/dspace-angular/pull/468 // 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); const url = decodeURIComponent(this.router.url);
this.searchService.getEndpoint().pipe( this.searchService.getEndpoint().pipe(
take(1), take(1),
tap((cachedHref: string) => this.requestService.removeByHrefSubstring(cachedHref)), tap((cachedHref: string) => this.requestService.removeByHrefSubstring(cachedHref)),
).subscribe(() => this.router.navigateByUrl(url)); ).subscribe(() => {
if (shouldNavigate) {
this.router.navigateByUrl(url);
}
});
} }
/** /**