Skip to content

Commit

Permalink
[DSC-1851] Force home page resolver to fetch site object without usin…
Browse files Browse the repository at this point in the history
…g the cached one
  • Loading branch information
atarix83 committed Nov 6, 2024
1 parent 278a1b7 commit 8b9d2a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/app/core/data/site-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,27 @@ export class SiteDataService extends IdentifiableDataService<Site> implements Fi

/**
* Retrieve the Site Object
*
* @param options Find list options object
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
* no valid cached version. Defaults to true
* @param reRequestOnStale Whether or not the request should automatically be re-
* requested after the response becomes stale
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
* {@link HALLink}s should be automatically resolved
* @return {Observable<RemoteData<PaginatedList<T>>>}
* Return an observable that emits object list
*/
find(): Observable<Site> {
find(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Site>[]): Observable<Site> {
const searchParams: RequestParam[] = [new RequestParam('projection', 'allLanguages')];
const options = Object.assign(new FindListOptions(), { searchParams });
return this.findAll(options).pipe(
const findOptions = Object.assign(new FindListOptions(), options, { searchParams });
return this.findAll(findOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
getFirstCompletedRemoteData(),
switchMap((remoteData: RemoteData<PaginatedList<Site>>) => {
if (remoteData.hasSucceeded) {
return of(remoteData.payload.page[0]);
} else {
return this.findAll().pipe(
return this.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
getFirstCompletedRemoteData(),
map((rd: RemoteData<PaginatedList<Site>>) => rd.hasSucceeded ? rd.payload.page[0] : null)
);
Expand Down
2 changes: 1 addition & 1 deletion src/app/home-page/home-page.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ export class HomePageResolver implements Resolve<Site> {
* @returns Observable<Site> Emits the found Site object, or an error if something went wrong
*/
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Site> | Promise<Site> | Site {
return this.siteService.find().pipe(take(1));
return this.siteService.find(null, false).pipe(take(1));
}
}

0 comments on commit 8b9d2a3

Please sign in to comment.