diff --git a/app/actions/index.ts b/app/actions/index.ts index a88a20a08..ed2218aca 100644 --- a/app/actions/index.ts +++ b/app/actions/index.ts @@ -18,21 +18,23 @@ function resolve(value: any, context: ActionContext): T { export function createAction(definition: Optional): Action { return { ...definition, - perform: (context) => { - // We muse use the specific analytics name here as the action name is - // translated and potentially contains user strings. - if (definition.analyticsName) { - Analytics.track("perform_action", definition.analyticsName, { - context: context.isButton - ? "button" - : context.isCommandBar - ? "commandbar" - : "contextmenu", - }); - } + perform: definition.perform + ? (context) => { + // We muse use the specific analytics name here as the action name is + // translated and potentially contains user strings. + if (definition.analyticsName) { + Analytics.track("perform_action", definition.analyticsName, { + context: context.isButton + ? "button" + : context.isCommandBar + ? "commandbar" + : "contextmenu", + }); + } - return definition.perform?.(context); - }, + return definition.perform?.(context); + } + : undefined, id: uuidv4(), }; } @@ -115,7 +117,7 @@ export function actionToKBar( keywords: action.keywords ?? "", shortcut: action.shortcut || [], icon: resolvedIcon, - perform: () => action.perform?.(context), + perform: action.perform ? () => action.perform?.(context) : undefined, }, // @ts-expect-error ts-migrate(2769) FIXME: No overload matches this call. ].concat(children.map((child) => ({ ...child, parent: action.id })));