diff --git a/src/app/+my-dspace-page/my-dspace-page.component.spec.ts b/src/app/+my-dspace-page/my-dspace-page.component.spec.ts index 27daa30a0f..f4b043f873 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.spec.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.spec.ts @@ -30,6 +30,8 @@ import { RoleService } from '../core/roles/role.service'; import { MockRoleService } from '../shared/mocks/mock-role-service'; import { SearchFixedFilterService } from '../+search-page/search-filters/search-filter/search-fixed-filter.service'; import { createSuccessfulRemoteDataObject$ } from '../shared/testing/utils'; +import { RequestService } from '../core/data/request.service'; +import { getMockRequestService } from '../shared/mocks/mock-request.service'; describe('MyDSpacePageComponent', () => { let comp: MyDSpacePageComponent; @@ -50,6 +52,7 @@ describe('MyDSpacePageComponent', () => { const mockResults = createSuccessfulRemoteDataObject$(['test', 'data']); const searchServiceStub = jasmine.createSpyObj('SearchService', { search: mockResults, + getEndpoint: observableOf('discover/search/objects'), getSearchLink: '/mydspace', getScopes: observableOf(['test-scope']), setServiceOptions: {} @@ -76,6 +79,7 @@ describe('MyDSpacePageComponent', () => { scope: scopeParam }) }; + const sidebarService = { isCollapsed: observableOf(true), collapse: () => this.isCollapsed = observableOf(true), @@ -125,6 +129,10 @@ describe('MyDSpacePageComponent', () => { { provide: SearchFixedFilterService, useValue: mockFixedFilterService + }, + { + provide: RequestService, + useValue: getMockRequestService() } ], schemas: [NO_ERRORS_SCHEMA] diff --git a/src/app/+my-dspace-page/my-dspace-page.component.ts b/src/app/+my-dspace-page/my-dspace-page.component.ts index 251bf50bd1..176d344352 100644 --- a/src/app/+my-dspace-page/my-dspace-page.component.ts +++ b/src/app/+my-dspace-page/my-dspace-page.component.ts @@ -28,6 +28,7 @@ import { SearchConfigurationService } from '../+search-page/search-service/searc import { MyDSpaceConfigurationService } from './my-dspace-configuration.service'; import { ViewMode } from '../core/shared/view-mode.model'; import { MyDSpaceRequest } from '../core/data/request.models'; +import { RequestService } from '../core/data/request.service'; export const MYDSPACE_ROUTE = '/mydspace'; export const SEARCH_CONFIG_SERVICE: InjectionToken = new InjectionToken('searchConfigurationService'); @@ -96,6 +97,7 @@ export class MyDSpacePageComponent implements OnInit { viewModeList = [ViewMode.List, ViewMode.Detail]; constructor(private service: SearchService, + private requestService: RequestService, private sidebarService: SearchSidebarService, private windowService: HostWindowService, @Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: MyDSpaceConfigurationService) { @@ -115,7 +117,8 @@ export class MyDSpacePageComponent implements OnInit { ngOnInit(): void { this.configurationList$ = this.searchConfigService.getAvailableConfigurationOptions(); this.searchOptions$ = this.searchConfigService.paginatedSearchOptions; - + // This assures an empty search cache each for each onInit() + this.service.getEndpoint().subscribe((url) => this.requestService.removeByHrefSubstring(url)); this.sub = this.searchOptions$.pipe( tap(() => this.resultsRD$.next(null)), switchMap((options: PaginatedSearchOptions) => this.service.search(options).pipe(getSucceededRemoteData()))) diff --git a/src/app/+search-page/search-service/search.service.ts b/src/app/+search-page/search-service/search.service.ts index bedae84eaa..5fcc86d079 100644 --- a/src/app/+search-page/search-service/search.service.ts +++ b/src/app/+search-page/search-service/search.service.ts @@ -97,14 +97,8 @@ export class SearchService implements OnDestroy { } } - /** - * Method to retrieve a paginated list of search results from the server - * @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search - * @param responseMsToLive The amount of milliseconds for the response to live in cache - * @returns {Observable>>>} Emits a paginated list with all search results found - */ - search(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number): Observable>>> { - const hrefObs = this.halService.getEndpoint(this.searchLinkPath).pipe( + getEndpoint(searchOptions?: PaginatedSearchOptions): Observable { + return this.halService.getEndpoint(this.searchLinkPath).pipe( map((url: string) => { if (hasValue(searchOptions)) { return (searchOptions as PaginatedSearchOptions).toRestUrl(url); @@ -113,6 +107,17 @@ export class SearchService implements OnDestroy { } }) ); + } + + /** + * Method to retrieve a paginated list of search results from the server + * @param {PaginatedSearchOptions} searchOptions The configuration necessary to perform this search + * @param responseMsToLive The amount of milliseconds for the response to live in cache + * @returns {Observable>>>} Emits a paginated list with all search results found + */ + search(searchOptions?: PaginatedSearchOptions, responseMsToLive?: number): Observable>>> { + + const hrefObs = this.getEndpoint(searchOptions); const requestObs = hrefObs.pipe( map((url: string) => { diff --git a/src/app/core/tasks/claimed-task-data.service.ts b/src/app/core/tasks/claimed-task-data.service.ts index 471d87461f..76e5e769d7 100644 --- a/src/app/core/tasks/claimed-task-data.service.ts +++ b/src/app/core/tasks/claimed-task-data.service.ts @@ -21,7 +21,6 @@ import { ProcessTaskResponse } from './models/process-task-response'; */ @Injectable() export class ClaimedTaskDataService extends TasksService { - protected responseMsToLive = 10 * 1000; protected responseMsToLive = 10 * 1000;