From 9f19fdceb26bdc4c6fdcc986f9c94ebf0e0bd5d2 Mon Sep 17 00:00:00 2001 From: Iku-turso Date: Wed, 12 Oct 2022 09:17:37 +0300 Subject: [PATCH] Simplify getting of composite paths Co-authored-by: Janne Savolainen Signed-off-by: Iku-turso --- .../get-composite-paths.ts | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/features/application-menu/main/menu-items/get-composite/get-composite-paths/get-composite-paths.ts b/src/features/application-menu/main/menu-items/get-composite/get-composite-paths/get-composite-paths.ts index f977cbcacd..46abf49f46 100644 --- a/src/features/application-menu/main/menu-items/get-composite/get-composite-paths/get-composite-paths.ts +++ b/src/features/application-menu/main/menu-items/get-composite/get-composite-paths/get-composite-paths.ts @@ -3,26 +3,10 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { pipeline } from "@ogre-tools/fp"; -import { flatMap } from "lodash/fp"; +import { map } from "lodash/fp"; import type { Composite } from "../get-composite"; +import { normalizeComposite } from "../normalize-composite/normalize-composite"; export const getCompositePaths = ( - composite: Composite, - previousPath: string[] = [], -): string[] => { - const currentPath = [...previousPath, composite.id]; - - const currentPathString = currentPath.join("."); - - return [ - currentPathString, - - ...pipeline( - composite.children, - - flatMap((childComposite) => - getCompositePaths(childComposite, currentPath), - ), - ), - ]; -}; + composite: Composite, +): string[] => pipeline(composite, normalizeComposite, map(([path]) => path));