1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

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-turso 2022-10-11 13:09:37 +03:00 committed by Janne Savolainen
parent 9c927b7f2d
commit 0e550d496c
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A

View File

@ -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 }),
);
});
},