MCPcopy Index your code
hub / github.com/BlueWallet/BlueWallet / buildMenu

Function buildMenu

components/TooltipMenu.helpers.ts:56–91  ·  view source on GitHub ↗
(actions: Action[] | Action[][], platform: Platform)

Source from the content-addressed store, hash-verified

54 * because its native menu doesn't render inline groups.
55 */
56export const buildMenu = (actions: Action[] | Action[][], platform: Platform): { items: ContextMenuAction[]; ids: IdNode[] } => {
57 const items: ContextMenuAction[] = [];
58 const ids: IdNode[] = [];
59
60 if (platform === 'ios') {
61 for (const group of actions) {
62 if (Array.isArray(group)) {
63 const inline = group.map(a => mapLeaf(a, platform)).filter((r): r is { item: ContextMenuAction; idNode: IdNode } => r !== null);
64 if (inline.length === 0) continue;
65 items.push({
66 title: '',
67 actions: inline.map(r => r.item),
68 inlineChildren: true,
69 } as ContextMenuAction);
70 // Synthetic inline group: no id of its own, only carries children.
71 ids.push({ children: inline.map(r => r.idNode) });
72 } else {
73 const r = mapLeaf(group, platform);
74 if (r) {
75 items.push(r.item);
76 ids.push(r.idNode);
77 }
78 }
79 }
80 return { items, ids };
81 }
82
83 for (const action of actions.flat()) {
84 const r = mapLeaf(action, platform);
85 if (r) {
86 items.push(r.item);
87 ids.push(r.idNode);
88 }
89 }
90 return { items, ids };
91};
92
93/**
94 * Resolve the original Action.id for a press event by walking the id-tree

Callers 2

ToolTipMenuFunction · 0.90

Calls 2

mapLeafFunction · 0.85
pushMethod · 0.45

Tested by

no test coverage detected