From e84af6ab916969442931ba4f0e0ad200008adda7 Mon Sep 17 00:00:00 2001 From: FrancescoMolinaro Date: Wed, 23 Apr 2025 15:07:00 +0200 Subject: [PATCH 1/3] [DURACOM-350] fix cache issue after mydspace action --- src/app/shared/mydspace-actions/mydspace-actions.ts | 6 +++++- .../mydspace-actions/mydspace-reloadable-actions.spec.ts | 4 +++- .../shared/mydspace-actions/mydspace-reloadable-actions.ts | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/shared/mydspace-actions/mydspace-actions.ts b/src/app/shared/mydspace-actions/mydspace-actions.ts index 5100d8122e..1a5ebbcc8c 100644 --- a/src/app/shared/mydspace-actions/mydspace-actions.ts +++ b/src/app/shared/mydspace-actions/mydspace-actions.ts @@ -101,13 +101,17 @@ export abstract class MyDSpaceActionsComponent { return false; }; // This assures that the search cache is empty before reloading mydspace. // See https://github.com/DSpace/dspace-angular/pull/468 + this.invalidateCacheForCurrentSearchUrl(); + } + + invalidateCacheForCurrentSearchUrl(): void { + const url = decodeURIComponent(this.router.url); this.searchService.getEndpoint().pipe( take(1), tap((cachedHref: string) => this.requestService.removeByHrefSubstring(cachedHref)), diff --git a/src/app/shared/mydspace-actions/mydspace-reloadable-actions.spec.ts b/src/app/shared/mydspace-actions/mydspace-reloadable-actions.spec.ts index 1d0d231503..b7a0a20219 100644 --- a/src/app/shared/mydspace-actions/mydspace-reloadable-actions.spec.ts +++ b/src/app/shared/mydspace-actions/mydspace-reloadable-actions.spec.ts @@ -219,6 +219,7 @@ describe('MyDSpaceReloadableActionsComponent', () => { spyOn(component, 'reloadObjectExecution').and.callThrough(); spyOn(component, 'convertReloadedObject').and.callThrough(); spyOn(component.processCompleted, 'emit').and.callThrough(); + spyOn(component, 'invalidateCacheForCurrentSearchUrl').and.callThrough(); (component as any).objectDataService = mockDataService; }); @@ -239,10 +240,11 @@ describe('MyDSpaceReloadableActionsComponent', () => { }); }); - it('should emit the reloaded object in case of success', (done) => { + it('should emit the reloaded object and invalidate cache in case of success', (done) => { component.startActionExecution().subscribe( (result) => { expect(component.processCompleted.emit).toHaveBeenCalledWith({ result: true, reloadedObject: result as any }); + expect(component.invalidateCacheForCurrentSearchUrl).toHaveBeenCalled(); done(); }); }); diff --git a/src/app/shared/mydspace-actions/mydspace-reloadable-actions.ts b/src/app/shared/mydspace-actions/mydspace-reloadable-actions.ts index 28e3ac4040..062bf25741 100644 --- a/src/app/shared/mydspace-actions/mydspace-reloadable-actions.ts +++ b/src/app/shared/mydspace-actions/mydspace-reloadable-actions.ts @@ -105,6 +105,8 @@ export abstract class MyDSpaceReloadableActionsComponent Date: Wed, 23 Apr 2025 15:47:01 +0200 Subject: [PATCH 2/3] [DURACOM-350] prevent unnecessary reload --- src/app/shared/mydspace-actions/mydspace-actions.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/app/shared/mydspace-actions/mydspace-actions.ts b/src/app/shared/mydspace-actions/mydspace-actions.ts index 1a5ebbcc8c..73caf4f30c 100644 --- a/src/app/shared/mydspace-actions/mydspace-actions.ts +++ b/src/app/shared/mydspace-actions/mydspace-actions.ts @@ -107,15 +107,19 @@ export abstract class MyDSpaceActionsComponent this.requestService.removeByHrefSubstring(cachedHref)), - ).subscribe(() => this.router.navigateByUrl(url)); + ).subscribe(() => { + if (shouldNavigate) { + this.router.navigateByUrl(url); + } + }); } /** From 7998d2d8b98ae0fc1966111f08117a1dbf0fe056 Mon Sep 17 00:00:00 2001 From: FrancescoMolinaro Date: Thu, 24 Apr 2025 09:28:29 +0200 Subject: [PATCH 3/3] [DURACOM-350] Fix filter skeleton missing update --- .../search-filter/search-filter.component.ts | 3 +-- .../search-filters/search-filters.component.html | 4 ++-- .../search-filters/search-filters.component.ts | 12 +----------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts index 03081581ee..80238c56ad 100644 --- a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts @@ -25,7 +25,6 @@ import { Subscription, switchMap, } from 'rxjs'; -import { take } from 'rxjs/operators'; import { RemoteData } from '../../../../core/data/remote-data'; import { SearchService } from '../../../../core/shared/search/search.service'; @@ -145,7 +144,7 @@ export class SearchFilterComponent implements OnInit, OnChanges, OnDestroy { this.filterService.expand(this.filter.name); } }), - this.getIsActive().pipe(take(1)).subscribe(() => { + this.getIsActive().subscribe(() => { this.isVisibilityComputed.emit(true); }), ); diff --git a/src/app/shared/search/search-filters/search-filters.component.html b/src/app/shared/search/search-filters/search-filters.component.html index 8ebfb4095b..bea2ea9467 100644 --- a/src/app/shared/search/search-filters/search-filters.component.html +++ b/src/app/shared/search/search-filters/search-filters.component.html @@ -5,14 +5,14 @@ } @if ((filters | async)?.hasSucceeded) { -
+
@for (filter of (filters | async)?.payload; track filter.name) { }
} -@if(getFinalFiltersComputed(this.currentConfiguration) !== (filters | async)?.payload?.length) { +@if(getCurrentFiltersComputed(this.currentConfiguration) < (filters | async)?.payload?.length) { } diff --git a/src/app/shared/search/search-filters/search-filters.component.ts b/src/app/shared/search/search-filters/search-filters.component.ts index aee3257614..ed1e83b717 100644 --- a/src/app/shared/search/search-filters/search-filters.component.ts +++ b/src/app/shared/search/search-filters/search-filters.component.ts @@ -251,18 +251,8 @@ export class SearchFiltersComponent implements OnInit { * @param configuration The configuration identifier to get the count for * @returns The number of computed filters, or 0 if none found */ - private getCurrentFiltersComputed(configuration: string) { + getCurrentFiltersComputed(configuration: string): number { const configFilter = this.findConfigInCurrentFilters(configuration); return configFilter?.filtersComputed || 0; } - - /** - * Gets the final number of computed filters for a specific configuration - * @param configuration The configuration identifier to get the count for - * @returns The number of computed filters in the final state, or 0 if none found - */ - getFinalFiltersComputed(configuration: string): number { - const configFilter = this.findConfigInFinalFilters(configuration); - return configFilter?.filtersComputed || 0; - } }