mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-27 11:51:13 +01:00
Conditionally disable auth
This commit is contained in:
@@ -6,20 +6,33 @@ import { invokeCmd } from '../lib/tauri';
|
||||
import { useActiveEnvironment } from './useActiveEnvironment';
|
||||
import { activeWorkspaceIdAtom } from './useActiveWorkspace';
|
||||
|
||||
export function useRenderTemplate(
|
||||
template: string,
|
||||
enabled: boolean,
|
||||
purpose: RenderPurpose,
|
||||
refreshKey: string | null,
|
||||
) {
|
||||
export function useRenderTemplate({
|
||||
template,
|
||||
enabled,
|
||||
purpose,
|
||||
refreshKey,
|
||||
ignoreError,
|
||||
preservePreviousValue,
|
||||
}: {
|
||||
template: string;
|
||||
enabled: boolean;
|
||||
purpose: RenderPurpose;
|
||||
refreshKey?: string | null;
|
||||
ignoreError?: boolean;
|
||||
preservePreviousValue?: boolean;
|
||||
}) {
|
||||
const workspaceId = useAtomValue(activeWorkspaceIdAtom) ?? 'n/a';
|
||||
const environmentId = useActiveEnvironment()?.id ?? null;
|
||||
return useQuery<string>({
|
||||
refetchOnWindowFocus: false,
|
||||
enabled,
|
||||
queryKey: ['render_template', workspaceId, environmentId, refreshKey, purpose],
|
||||
placeholderData: preservePreviousValue ? (prev) => prev : undefined,
|
||||
queryKey: ['render_template', workspaceId, environmentId, refreshKey, purpose, ignoreError],
|
||||
queryFn: () =>
|
||||
minPromiseMillis(renderTemplate({ template, workspaceId, environmentId, purpose }), 300),
|
||||
minPromiseMillis(
|
||||
renderTemplate({ template, workspaceId, environmentId, purpose, ignoreError }),
|
||||
300,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -28,13 +41,21 @@ export async function renderTemplate({
|
||||
workspaceId,
|
||||
environmentId,
|
||||
purpose,
|
||||
ignoreError,
|
||||
}: {
|
||||
template: string;
|
||||
workspaceId: string;
|
||||
environmentId: string | null;
|
||||
purpose: RenderPurpose;
|
||||
ignoreError?: boolean;
|
||||
}): Promise<string> {
|
||||
return invokeCmd('cmd_render_template', { template, workspaceId, environmentId, purpose });
|
||||
return invokeCmd('cmd_render_template', {
|
||||
template,
|
||||
workspaceId,
|
||||
environmentId,
|
||||
purpose,
|
||||
ignoreError,
|
||||
});
|
||||
}
|
||||
|
||||
export async function decryptTemplate({
|
||||
|
||||
Reference in New Issue
Block a user