Skip to content

Commit

Permalink
fix: pr-reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
eirikhaugstulen committed Dec 7, 2023
1 parent eeeb26d commit 3ad9447
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,19 @@ const getLinkedEntityData = (apiLinkedEntity, relationshipCreatedAt, pendingApiR
return null;
};

export const determineLinkedEntity = (fromEntity: ApiLinkedEntity, toEntity: ApiLinkedEntity, sourceId: string) => {
if (fromEntity.trackedEntity?.trackedEntity === sourceId || fromEntity.event?.event === sourceId) {
return toEntity;
}
export const determineLinkedEntity =
(fromEntity: ApiLinkedEntity, toEntity: ApiLinkedEntity, sourceId: string): ApiLinkedEntity | null => {
if (fromEntity.trackedEntity?.trackedEntity === sourceId || fromEntity.event?.event === sourceId) {
return toEntity;
}

if (toEntity.trackedEntity?.trackedEntity === sourceId || toEntity.event?.event === sourceId) {
return fromEntity;
}
if (toEntity.trackedEntity?.trackedEntity === sourceId || toEntity.event?.event === sourceId) {
return fromEntity;
}

log.error(errorCreator('Could not determine linked entity')({ fromEntity, toEntity, sourceId }));
return null;
};
log.error(errorCreator('Could not determine linked entity')({ fromEntity, toEntity, sourceId }));
return null;
};

export const useGroupedLinkedEntities = (
sourceId: string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ export const useRelationships = ({ entityId, searchMode, relationshipTypes }: Pr
const { from, to } = relationship;
const apiLinkedEntity = determineLinkedEntity(from, to, entityId);

if (!apiLinkedEntity) {
return acc;
}

if (!relationshipType.bidirectional && apiLinkedEntity === from) {
return acc;
}
Expand Down

0 comments on commit 3ad9447

Please sign in to comment.