mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-19 01:57:41 +01:00
21 lines
619 B
TypeScript
21 lines
619 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import type { GetTemplateFunctionsResponse } from '@yaakapp-internal/plugin';
|
|
import { invokeCmd } from '../lib/tauri';
|
|
import { usePluginsKey } from './usePlugins';
|
|
|
|
export function useTemplateFunctions() {
|
|
const pluginsKey = usePluginsKey();
|
|
|
|
const result = useQuery({
|
|
queryKey: ['template_functions', pluginsKey],
|
|
queryFn: async () => {
|
|
const responses = (await invokeCmd(
|
|
'cmd_template_functions',
|
|
)) as GetTemplateFunctionsResponse[];
|
|
return responses;
|
|
},
|
|
});
|
|
|
|
return result.data?.flatMap((r) => r.functions) ?? [];
|
|
}
|