[sync] fix: share view and template call unnecessary api (#1484) (#2793)

Synced from teableio/teable-ee@9c0fd6f

Co-authored-by: Aries X <caoxing9@gmail.com>
This commit is contained in:
Bieber 2026-03-21 00:09:24 +08:00 committed by GitHub
parent 90e3561ac6
commit 9d20ee508d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,13 +1,14 @@
import { useQuery } from '@tanstack/react-query';
import { getAIConfig } from '@teable/openapi';
import { useBaseId } from '@teable/sdk/hooks';
import { useBaseId, useIsReadOnlyPreview } from '@teable/sdk/hooks';
export function useAI() {
const baseId = useBaseId() as string;
const isReadOnlyPreview = useIsReadOnlyPreview();
const { data } = useQuery({
queryKey: ['ai-config', baseId],
queryFn: () => getAIConfig(baseId).then(({ data }) => data),
enabled: Boolean(baseId),
enabled: Boolean(baseId) && !isReadOnlyPreview,
});
return {