mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 15:09:10 +00:00
refactor: improve typing on transform (#626)
* refactor: improve typing on transform * chore: use placeholder for data errors
This commit is contained in:
@@ -1,7 +1,4 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
//@ts-nocheck -- working on it
|
|
||||||
import { useMutation, useQuery } from '@tanstack/react-query';
|
import { useMutation, useQuery } from '@tanstack/react-query';
|
||||||
import { OSCSettings } from 'ontime-types';
|
|
||||||
|
|
||||||
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
|
||||||
import { OSC_SETTINGS } from '../api/apiConstants';
|
import { OSC_SETTINGS } from '../api/apiConstants';
|
||||||
@@ -13,7 +10,10 @@ import { ontimeQueryClient } from '../queryClient';
|
|||||||
export default function useOscSettings() {
|
export default function useOscSettings() {
|
||||||
const { data, status, isFetching, isError, refetch } = useQuery({
|
const { data, status, isFetching, isError, refetch } = useQuery({
|
||||||
queryKey: OSC_SETTINGS,
|
queryKey: OSC_SETTINGS,
|
||||||
queryFn: getOSC,
|
queryFn: async () => {
|
||||||
|
const oscData = await getOSC();
|
||||||
|
return { ...oscData, portIn: String(oscData.portIn), portOut: String(oscData.portOut) };
|
||||||
|
},
|
||||||
placeholderData: oscPlaceholderSettings,
|
placeholderData: oscPlaceholderSettings,
|
||||||
retry: 5,
|
retry: 5,
|
||||||
retryDelay: (attempt: number) => attempt * 2500,
|
retryDelay: (attempt: number) => attempt * 2500,
|
||||||
@@ -21,8 +21,7 @@ export default function useOscSettings() {
|
|||||||
networkMode: 'always',
|
networkMode: 'always',
|
||||||
});
|
});
|
||||||
|
|
||||||
// we need to jump through some hoops because of the type op port
|
return { data: data ?? oscPlaceholderSettings, status, isFetching, isError, refetch };
|
||||||
return { data: data! as unknown as OSCSettings, status, isFetching, isError, refetch };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useOscSettingsMutation() {
|
export function useOscSettingsMutation() {
|
||||||
|
|||||||
@@ -1,5 +1,3 @@
|
|||||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
||||||
//@ts-nocheck -- working on it
|
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { FormControl, Input, Switch } from '@chakra-ui/react';
|
import { FormControl, Input, Switch } from '@chakra-ui/react';
|
||||||
@@ -59,7 +57,6 @@ export default function OscSettings() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
// @ts-expect-error -- we know the types dont match
|
|
||||||
reset(data);
|
reset(data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user