import { useQuery, keepPreviousData } from '@tanstack/react-query';
import { fetchLocalTasks } from '../api';
import { POLLING } from '../lib/constants.js';

export function useLocalTaskList() {
  return useQuery({
    queryKey: ['localTasks'],
    queryFn: fetchLocalTasks,
    refetchInterval: POLLING.FAST,
    refetchIntervalInBackground: true,
    select: data => data ?? [],
    placeholderData: keepPreviousData,
  });
}
