Files
ontime/client/src/common/hooks-query/useOscSettings.ts
T
Carlos Valente 6f634c36f9 v2 alpha 3 (#272)
* style: correct background colours

* chore: add folder resolutions to vite

* refactor: add auto refetch to HTTP APIs

* fix: view settings override endpoint

* refactor: memoize callbacks

* fix: reorder reaching wrong data adapter

* refactor: memoize callbacks

* style: presentation cleanup

* fix(delete): prevent flow with deleted event in playback

* refactor: convert to typescript

* refactor: small fixes and typescript conversion

* ux: improve feedback on local changes

* refactor: cleanup props
2022-12-26 09:40:33 +01:00

25 lines
649 B
TypeScript

import { useQuery } from '@tanstack/react-query';
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
import { OSC_SETTINGS } from '../api/apiConstants';
import { getOSC } from '../api/ontimeApi';
import { oscPlaceholderSettings } from '../models/OscSettings.type';
export default function useOscSettings() {
const {
data,
status,
isError,
refetch,
} = useQuery({
queryKey: OSC_SETTINGS,
queryFn: getOSC,
placeholderData: oscPlaceholderSettings,
retry: 5,
retryDelay: attempt => attempt * 2500,
refetchInterval: queryRefetchIntervalSlow,
});
return { data, status, isError, refetch };
}