@@ -28,14 +28,19 @@ import {
2828 isNotEmptyOperator ,
2929} from '../../../shared/empty.util' ;
3030import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model' ;
31- import { getLinkDefinition } from '../../cache/builders/build-decorators' ;
31+ import {
32+ getLinkDefinition ,
33+ LinkDefinition ,
34+ } from '../../cache/builders/build-decorators' ;
3235import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service' ;
3336import { CacheableObject } from '../../cache/cacheable-object.model' ;
3437import { RequestParam } from '../../cache/models/request-param.model' ;
3538import { ObjectCacheEntry } from '../../cache/object-cache.reducer' ;
3639import { ObjectCacheService } from '../../cache/object-cache.service' ;
40+ import { GenericConstructor } from '../../shared/generic-constructor' ;
3741import { HALEndpointService } from '../../shared/hal-endpoint.service' ;
3842import { HALLink } from '../../shared/hal-link.model' ;
43+ import { HALResource } from '../../shared/hal-resource.model' ;
3944import { getFirstCompletedRemoteData } from '../../shared/operators' ;
4045import { URLCombiner } from '../../url-combiner/url-combiner' ;
4146import { FindListOptions } from '../find-list-options.model' ;
@@ -303,7 +308,7 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
303308 if ( hasValue ( remoteDataObject ?. payload ?. _links ) ) {
304309 for ( const followLinkName of Object . keys ( remoteDataObject . payload . _links ) ) {
305310 // only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name
306- const linkDefinition = getLinkDefinition ( ( remoteDataObject . payload as any ) . constructor , followLinkName ) ;
311+ const linkDefinition = this . getLinkDefinition ( ( remoteDataObject . payload as any ) . constructor , followLinkName ) ;
307312 if ( linkDefinition ?. propertyName && hasValue ( remoteDataObject . payload [ linkDefinition . propertyName ] ) && followLinkName !== 'self' ) {
308313 // followLink can be either an individual HALLink or a HALLink[]
309314 const followLinksList : HALLink [ ] = [ ] . concat ( remoteDataObject . payload . _links [ followLinkName ] ) ;
@@ -359,8 +364,8 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
359364 if ( hasValue ( object ?. _links ) ) {
360365 for ( const followLinkName of Object . keys ( object . _links ) ) {
361366 // only add the followLinks if they are embedded, and we get only links from the linkMap with the correct name
362- const linkDefinition = getLinkDefinition ( ( remoteDataObject . payload as any ) . constructor , followLinkName ) ;
363- if ( linkDefinition ?. propertyName && hasValue ( remoteDataObject . payload [ linkDefinition . propertyName ] ) && followLinkName !== 'self' ) {
367+ const linkDefinition = this . getLinkDefinition ( ( remoteDataObject . payload as any ) . constructor , followLinkName ) ;
368+ if ( linkDefinition ?. propertyName && followLinkName !== 'self' && hasValue ( object [ linkDefinition . propertyName ] ) ) {
364369 // followLink can be either an individual HALLink or a HALLink[]
365370 const followLinksList : HALLink [ ] = [ ] . concat ( object . _links [ followLinkName ] ) ;
366371 for ( const individualFollowLink of followLinksList ) {
@@ -515,4 +520,9 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
515520
516521 return done$ ;
517522 }
523+
524+ getLinkDefinition < D extends HALResource > ( source : GenericConstructor < D > , linkName : keyof D [ '_links' ] ) : LinkDefinition < D > {
525+ return getLinkDefinition ( source , linkName ) ;
526+ }
527+
518528}
0 commit comments