Simplify creation of composite

Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>

Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
Iku-tursoandJanne Savolainen authored and Janne Savolainen committed 2022-10-20 08:39:18 +03:00
1 parent 9c927b7f2d
commit 0e550d496c
1 file changed
+12 -9
@@ -8,10 +8,9 @@ import type { Composite } from "./menu-items/get-composite/get-composite";
import getComposite from "./menu-items/get-composite/get-composite";
import { computed } from "mobx";
import { pipeline } from "@ogre-tools/fp";
import { get } from "lodash/fp";
import type { ApplicationMenuItemTypes } from "./menu-items/application-menu-item-injection-token";
export interface MenuItemRoot { id: "root"; kind: "root"; orderNumber: 0 }
export interface MenuItemRoot { id: "root"; parentId: undefined; kind: "root"; orderNumber: 0 }
const applicationMenuItemCompositeInjectable = getInjectable({
id: "application-menu-item-composite",
@@ -23,14 +22,18 @@ const applicationMenuItemCompositeInjectable = getInjectable({
const items = menuItems.get();
return pipeline(
[{ id: "root" as const, kind: "root" as const, orderNumber: 0 as const }, ...items],
[
{
id: "root" as const,
parentId: undefined,
kind: "root" as const,
orderNumber: 0 as const,
},
x => getComposite({
source: x,
rootId: "root",
getId: get("id"),
getParentId: get("parentId"),
}),
...items,
],
(x) => getComposite({ source: x }),
);
});
},