mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-08 00:43:54 +00:00
23a44b2f04
* refactor: replace traslation hook refetch time with stale time * refactor: make it the service responsebillety to send refetch keys for asset changes
17 lines
596 B
TypeScript
17 lines
596 B
TypeScript
import { useQuery } from '@tanstack/react-query';
|
|
import { langEn } from 'ontime-types';
|
|
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
|
|
|
import { getUserTranslation } from '../../common/api/assets';
|
|
import { TRANSLATION } from '../../common/api/constants';
|
|
|
|
export function useCustomTranslation() {
|
|
const { data, status, refetch } = useQuery({
|
|
queryKey: TRANSLATION,
|
|
queryFn: ({ signal }) => getUserTranslation({ signal }),
|
|
placeholderData: (previousData, _previousQuery) => previousData,
|
|
staleTime: MILLIS_PER_HOUR,
|
|
});
|
|
return { data: data ?? langEn, status, refetch };
|
|
}
|