mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-07 08:23:55 +00:00
01c2ef4c4d
* refactor: rename settings panel * style: typo * style: fix blackout position * fix: offset time in time-to-end * refactor: operator is protected * style: tweaks to pincode * refactor: close params editor on submit * refactor: same navigation in all pages * refactor: use cached response
25 lines
783 B
TypeScript
25 lines
783 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { ProjectFileListResponse } from 'ontime-types';
|
|
|
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
|
import { PROJECT_LIST } from '../api/constants';
|
|
import { getProjects } from '../api/db';
|
|
|
|
const placeholderProjectList: ProjectFileListResponse = {
|
|
files: [],
|
|
lastLoadedProject: '',
|
|
};
|
|
|
|
export function useProjectList() {
|
|
const { data, status, refetch } = useQuery({
|
|
queryKey: PROJECT_LIST,
|
|
queryFn: getProjects,
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
retry: 5,
|
|
retryDelay: (attempt: number) => attempt * 2500,
|
|
refetchInterval: queryRefetchIntervalSlow,
|
|
networkMode: 'always',
|
|
});
|
|
return { data: data ?? placeholderProjectList, status, refetch };
|
|
}
|