Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/app/shared/mydspace-actions/mydspace-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,25 @@ export abstract class MyDSpaceActionsComponent<T extends DSpaceObject, TService
reload(): void {

this.router.navigated = false;
const url = decodeURIComponent(this.router.url);
// override the route reuse strategy
this.router.routeReuseStrategy.shouldReuseRoute = () => {
return false;
};
// This assures that the search cache is empty before reloading mydspace.
// See https://github.com/DSpace/dspace-angular/pull/468
this.invalidateCacheForCurrentSearchUrl(true);
}

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);
}
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand All @@ -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();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ export abstract class MyDSpaceReloadableActionsComponent<T extends DSpaceObject,
if (result) {
if (reloadedObject) {
this.processCompleted.emit({ result, reloadedObject });
// Ensure that next time the page is requested the objects have the correct render type.
this.invalidateCacheForCurrentSearchUrl();
} else {
this.reload();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ <h2>{{filterLabel+'.filters.head' | translate}}</h2>
}

@if ((filters | async)?.hasSucceeded) {
<div [class.visually-hidden]="getFinalFiltersComputed(this.currentConfiguration) !== (filters | async)?.payload?.length">
<div [class.visually-hidden]="getCurrentFiltersComputed(this.currentConfiguration) < (filters | async)?.payload?.length">
@for (filter of (filters | async)?.payload; track filter.name) {
<ds-search-filter (isVisibilityComputed)="countFiltersWithComputedVisibility($event)" [scope]="currentScope" [filter]="filter" [inPlaceSearch]="inPlaceSearch" [refreshFilters]="refreshFilters"></ds-search-filter>
}
</div>
}

@if(getFinalFiltersComputed(this.currentConfiguration) !== (filters | async)?.payload?.length) {
@if(getCurrentFiltersComputed(this.currentConfiguration) < (filters | async)?.payload?.length) {
<ngx-skeleton-loader [count]="defaultFilterCount"/>
}

Expand Down
12 changes: 1 addition & 11 deletions src/app/shared/search/search-filters/search-filters.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Loading