MCPcopy Create free account
hub / github.com/callumalpass/tasknotes / toggleContextInList

Function toggleContextInList

src/components/TaskContextMenu.ts:108–118  ·  view source on GitHub ↗
(
	contexts: string[] | undefined,
	context: string
)

Source from the content-addressed store, hash-verified

106}
107
108export function toggleContextInList(
109 contexts: string[] | undefined,
110 context: string
111): string[] | undefined {
112 const value = normalizeContextValue(context);
113 const current = normalizeContextList(contexts);
114 if (!value) return current.length > 0 ? current : undefined;
115 return current.includes(value)
116 ? removeContextFromList(current, value)
117 : addContextToList(current, value);
118}
119
120function getSubmenu(item: MenuItem): Menu {
121 return (item as unknown as SubmenuMenuItem).setSubmenu();

Calls 4

normalizeContextValueFunction · 0.85
normalizeContextListFunction · 0.85
removeContextFromListFunction · 0.85
addContextToListFunction · 0.85

Tested by

no test coverage detected