* WIP * WIP - MultiObjectSearch * WIP * WIP * Finished working version * Fix * Fixed and cleaned * Fix * Disabled files and emails for custom objects * Cleaned console.log * Fixed attachment * Fixed * fix lint --------- Co-authored-by: Charles Bochet <charles@twenty.com>
22 lines
744 B
TypeScript
22 lines
744 B
TypeScript
import { ActivityTargetableObject } from '../types/ActivityTargetableEntity';
|
|
|
|
export const flattenTargetableObjectsAndTheirRelatedTargetableObjects = (
|
|
targetableObjectsWithRelatedTargetableObjects: ActivityTargetableObject[],
|
|
): ActivityTargetableObject[] => {
|
|
const flattenedTargetableObjects: ActivityTargetableObject[] = [];
|
|
|
|
for (const targetableObject of targetableObjectsWithRelatedTargetableObjects ??
|
|
[]) {
|
|
flattenedTargetableObjects.push(targetableObject);
|
|
|
|
if (targetableObject.relatedTargetableObjects) {
|
|
for (const relatedEntity of targetableObject.relatedTargetableObjects ??
|
|
[]) {
|
|
flattenedTargetableObjects.push(relatedEntity);
|
|
}
|
|
}
|
|
}
|
|
|
|
return flattenedTargetableObjects;
|
|
};
|