Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | 1x 1x 1x 1x 1x 6x 6x 1x 5x 5x 3x 2x 1x | import { ArticleService } from '../../../services/articles';
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, ResolveFn } from '@angular/router';
import { ArticleVersion } from '@drevo-web/shared';
import { Observable, of } from 'rxjs';
import { catchError } from 'rxjs/operators';
/**
* Pure function for resolving article version data from route params.
* Reads :versionId param and calls getArticleVersion().
*/
export function resolveArticleVersion(
articleService: ArticleService,
route: ActivatedRouteSnapshot,
): Observable<ArticleVersion | undefined> {
const idParam = route.paramMap.get('versionId');
if (!idParam) {
return of(undefined);
}
const id = Number(idParam);
if (isNaN(id) || id <= 0) {
return of(undefined);
}
return articleService.getArticleVersion(id).pipe(catchError(() => of(undefined)));
}
export const articleVersionResolver: ResolveFn<ArticleVersion | undefined> = route =>
resolveArticleVersion(inject(ArticleService), route);
|