From 5e21bfa5ca2369b4659efeb6e34daa9d23fbf10a Mon Sep 17 00:00:00 2001 From: Kristof De Langhe Date: Tue, 13 Oct 2020 13:28:47 +0200 Subject: [PATCH] 74053: fix issue #865 --- .../core/breadcrumbs/dso-breadcrumb.resolver.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts index 09292fec21..9d04083749 100644 --- a/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts +++ b/src/app/core/breadcrumbs/dso-breadcrumb.resolver.ts @@ -4,11 +4,12 @@ import { ActivatedRouteSnapshot, Resolve, RouterStateSnapshot } from '@angular/r import { DSOBreadcrumbsService } from './dso-breadcrumbs.service'; import { DataService } from '../data/data.service'; import { getRemoteDataPayload, getSucceededRemoteData } from '../shared/operators'; -import { map } from 'rxjs/operators'; +import { filter, find, map, take } from 'rxjs/operators'; import { Observable } from 'rxjs'; import { DSpaceObject } from '../shared/dspace-object.model'; import { ChildHALResource } from '../shared/child-hal-resource.model'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; +import { hasValue } from '../../shared/empty.util'; /** * The class that resolves the BreadcrumbConfig object for a DSpaceObject @@ -29,12 +30,17 @@ export abstract class DSOBreadcrumbResolver> { const uuid = route.params.id; return this.dataService.findById(uuid, ...this.followLinks).pipe( - getSucceededRemoteData(), + filter((rd) => hasValue(rd.error) || hasValue(rd.payload)), + take(1), getRemoteDataPayload(), map((object: T) => { - const fullPath = state.url; - const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid; - return { provider: this.breadcrumbService, key: object, url: url }; + if (hasValue(object)) { + const fullPath = state.url; + const url = fullPath.substr(0, fullPath.indexOf(uuid)) + uuid; + return {provider: this.breadcrumbService, key: object, url: url}; + } else { + return undefined; + } }) ); }