Skip to content

Commit a862d84

Browse files
committed
fix: use the correct link name for find by href
1 parent 973fd33 commit a862d84

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
isNotEmptyOperator,
2929
} from '../../../shared/empty.util';
3030
import { FollowLinkConfig } from '../../../shared/utils/follow-link-config.model';
31+
import { getLinkDefinition } from '../../cache/builders/build-decorators';
3132
import { RemoteDataBuildService } from '../../cache/builders/remote-data-build.service';
3233
import { CacheableObject } from '../../cache/cacheable-object.model';
3334
import { RequestParam } from '../../cache/models/request-param.model';
@@ -301,8 +302,9 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
301302
tap((remoteDataObject: RemoteData<T>) => {
302303
if (hasValue(remoteDataObject?.payload?._links)) {
303304
for (const followLinkName of Object.keys(remoteDataObject.payload._links)) {
304-
// only add the followLinks if they are embedded
305-
if (hasValue(remoteDataObject.payload[followLinkName]) && followLinkName !== 'self') {
305+
// 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);
307+
if (linkDefinition?.propertyName && hasValue(remoteDataObject.payload[linkDefinition.propertyName]) && followLinkName !== 'self') {
306308
// followLink can be either an individual HALLink or a HALLink[]
307309
const followLinksList: HALLink[] = [].concat(remoteDataObject.payload._links[followLinkName]);
308310
for (const individualFollowLink of followLinksList) {

0 commit comments

Comments
 (0)