1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Refactor query keys to enum

This commit is contained in:
viown 2025-02-23 17:38:31 +03:00
parent dd539b89ca
commit a7621d242d
7 changed files with 18 additions and 15 deletions

View file

@ -3,7 +3,7 @@ import Page from 'components/Page';
import globalize from 'lib/globalize';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import { QUERY_KEY, useTasks } from '../../features/tasks/api/useTasks';
import { useTasks } from '../../features/tasks/api/useTasks';
import { getCategories, getTasksByCategory } from '../../features/tasks/utils/tasks';
import Loading from 'components/loading/LoadingComponent';
import Tasks from '../../features/tasks/components/Tasks';
@ -14,6 +14,7 @@ import Events, { Event } from 'utils/events';
import { ApiClient } from 'jellyfin-apiclient';
import { useApi } from 'hooks/useApi';
import { queryClient } from 'utils/query/queryClient';
import { QueryKey } from 'apps/dashboard/features/tasks/api/queryKey';
export const Component = () => {
const { __legacyApiClient__ } = useApi();
@ -22,13 +23,13 @@ export const Component = () => {
// TODO: Replace usage of the legacy apiclient when websocket support is added to the TS SDK.
useEffect(() => {
const onScheduledTasksUpdate = (_e: Event, _apiClient: ApiClient, info: TaskInfo[]) => {
queryClient.setQueryData([ QUERY_KEY ], info);
queryClient.setQueryData([ QueryKey.Tasks ], info);
};
const fallbackInterval = setInterval(() => {
if (!__legacyApiClient__?.isMessageChannelOpen()) {
void queryClient.invalidateQueries({
queryKey: [ QUERY_KEY ]
queryKey: [ QueryKey.Tasks ]
});
}
}, 1e4);