Spaces:
Paused
Paused
File size: 611 Bytes
4efde5d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | 'use client';
import { createQueryHook } from '@/hooks/use-query';
import { getThreads } from '@/lib/api';
import { threadKeys } from './keys';
export const useThreadsByProject = (projectId?: string) =>
createQueryHook(
threadKeys.byProject(projectId || ''),
() => projectId ? getThreads(projectId) : Promise.resolve([]),
{
enabled: !!projectId,
staleTime: 2 * 60 * 1000,
refetchOnWindowFocus: false,
}
)();
export const useAllThreads = createQueryHook(
threadKeys.all,
() => getThreads(),
{
staleTime: 2 * 60 * 1000,
refetchOnWindowFocus: false,
}
); |