Submatter/apps/web/components/ai/composer-events.ts

13 lines
282 B
TypeScript
Raw Permalink Normal View History

export function submitComposer<Event extends { preventDefault(): void }>(
event: Event,
input: string,
busy: boolean,
submit: (event: Event) => void,
focus: () => void,
): void {
event.preventDefault();
if (busy || !input.trim()) return;
submit(event);
focus();
}