refactor: improve the amount of GET requests for translation assets (#2058)

* refactor: replace traslation hook refetch time with stale time

* refactor: make it the service responsebillety to send refetch keys for asset changes
This commit is contained in:
Alex Christoffer Rasmussen
2026-04-14 09:30:27 +02:00
committed by GitHub
parent 2d3c8e7eb2
commit 23a44b2f04
3 changed files with 12 additions and 7 deletions
@@ -1,16 +1,16 @@
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';
import { queryRefetchIntervalSlow } from '../../ontimeConfig';
export function useCustomTranslation() {
const { data, status, refetch } = useQuery({
queryKey: TRANSLATION,
queryFn: ({ signal }) => getUserTranslation({ signal }),
placeholderData: (previousData, _previousQuery) => previousData,
refetchInterval: queryRefetchIntervalSlow,
staleTime: MILLIS_PER_HOUR,
});
return { data: data ?? langEn, status, refetch };
}