Skip to content

Commit 8b9d2a3

Browse files
committed
[DSC-1851] Force home page resolver to fetch site object without using the cached one
1 parent 278a1b7 commit 8b9d2a3

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/app/core/data/site-data.service.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,27 @@ export class SiteDataService extends IdentifiableDataService<Site> implements Fi
4646

4747
/**
4848
* Retrieve the Site Object
49+
*
50+
* @param options Find list options object
51+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
52+
* no valid cached version. Defaults to true
53+
* @param reRequestOnStale Whether or not the request should automatically be re-
54+
* requested after the response becomes stale
55+
* @param linksToFollow List of {@link FollowLinkConfig} that indicate which
56+
* {@link HALLink}s should be automatically resolved
57+
* @return {Observable<RemoteData<PaginatedList<T>>>}
58+
* Return an observable that emits object list
4959
*/
50-
find(): Observable<Site> {
60+
find(options?: FindListOptions, useCachedVersionIfAvailable?: boolean, reRequestOnStale?: boolean, ...linksToFollow: FollowLinkConfig<Site>[]): Observable<Site> {
5161
const searchParams: RequestParam[] = [new RequestParam('projection', 'allLanguages')];
52-
const options = Object.assign(new FindListOptions(), { searchParams });
53-
return this.findAll(options).pipe(
62+
const findOptions = Object.assign(new FindListOptions(), options, { searchParams });
63+
return this.findAll(findOptions, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
5464
getFirstCompletedRemoteData(),
5565
switchMap((remoteData: RemoteData<PaginatedList<Site>>) => {
5666
if (remoteData.hasSucceeded) {
5767
return of(remoteData.payload.page[0]);
5868
} else {
59-
return this.findAll().pipe(
69+
return this.findAll(options, useCachedVersionIfAvailable, reRequestOnStale, ...linksToFollow).pipe(
6070
getFirstCompletedRemoteData(),
6171
map((rd: RemoteData<PaginatedList<Site>>) => rd.hasSucceeded ? rd.payload.page[0] : null)
6272
);

src/app/home-page/home-page.resolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ export class HomePageResolver implements Resolve<Site> {
2020
* @returns Observable<Site> Emits the found Site object, or an error if something went wrong
2121
*/
2222
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<Site> | Promise<Site> | Site {
23-
return this.siteService.find().pipe(take(1));
23+
return this.siteService.find(null, false).pipe(take(1));
2424
}
2525
}

0 commit comments

Comments
 (0)