diff --git a/src/apps/dashboard/features/tasks/api/queryKey.ts b/src/apps/dashboard/features/tasks/api/queryKey.ts deleted file mode 100644 index 83d23b3568..0000000000 --- a/src/apps/dashboard/features/tasks/api/queryKey.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum QueryKey { - Task = 'Task', - Tasks = 'Tasks' -}; diff --git a/src/apps/dashboard/features/tasks/api/useStartTask.ts b/src/apps/dashboard/features/tasks/api/useStartTask.ts index 5258904ae3..ef37b7e6e8 100644 --- a/src/apps/dashboard/features/tasks/api/useStartTask.ts +++ b/src/apps/dashboard/features/tasks/api/useStartTask.ts @@ -3,7 +3,7 @@ import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-task import { useMutation } from '@tanstack/react-query'; import { useApi } from 'hooks/useApi'; import { queryClient } from 'utils/query/queryClient'; -import { QueryKey } from './queryKey'; +import { QUERY_KEY } from './useTasks'; export const useStartTask = () => { const { api } = useApi(); @@ -15,7 +15,7 @@ export const useStartTask = () => { ), onSuccess: () => { void queryClient.invalidateQueries({ - queryKey: [ QueryKey.Tasks ] + queryKey: [ QUERY_KEY ] }); } }); diff --git a/src/apps/dashboard/features/tasks/api/useStopTask.ts b/src/apps/dashboard/features/tasks/api/useStopTask.ts index 49ce910c7f..30421ee6af 100644 --- a/src/apps/dashboard/features/tasks/api/useStopTask.ts +++ b/src/apps/dashboard/features/tasks/api/useStopTask.ts @@ -3,7 +3,7 @@ import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-task import { useMutation } from '@tanstack/react-query'; import { useApi } from 'hooks/useApi'; import { queryClient } from 'utils/query/queryClient'; -import { QueryKey } from './queryKey'; +import { QUERY_KEY } from './useTasks'; export const useStopTask = () => { const { api } = useApi(); @@ -15,7 +15,7 @@ export const useStopTask = () => { ), onSuccess: () => { void queryClient.invalidateQueries({ - queryKey: [ QueryKey.Tasks ] + queryKey: [ QUERY_KEY ] }); } }); diff --git a/src/apps/dashboard/features/tasks/api/useTask.ts b/src/apps/dashboard/features/tasks/api/useTask.ts index 9ced51614b..9df4adaefa 100644 --- a/src/apps/dashboard/features/tasks/api/useTask.ts +++ b/src/apps/dashboard/features/tasks/api/useTask.ts @@ -5,7 +5,7 @@ import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-task import { useQuery } from '@tanstack/react-query'; import { useApi } from 'hooks/useApi'; -import { QueryKey } from './queryKey'; +import { QUERY_KEY } from './useTasks'; const fetchTask = async ( api: Api, @@ -21,7 +21,7 @@ export const useTask = (params: ScheduledTasksApiGetTaskRequest) => { const { api } = useApi(); return useQuery({ - queryKey: [ QueryKey.Task, params.taskId ], + queryKey: [ QUERY_KEY, params.taskId ], queryFn: ({ signal }) => fetchTask(api!, params, { signal }), enabled: !!api diff --git a/src/apps/dashboard/features/tasks/api/useTasks.ts b/src/apps/dashboard/features/tasks/api/useTasks.ts index 592d4c4c94..7a4b6e1c4d 100644 --- a/src/apps/dashboard/features/tasks/api/useTasks.ts +++ b/src/apps/dashboard/features/tasks/api/useTasks.ts @@ -5,7 +5,8 @@ import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-task import { useQuery } from '@tanstack/react-query'; import { useApi } from 'hooks/useApi'; -import { QueryKey } from './queryKey'; + +export const QUERY_KEY = 'Tasks'; const fetchTasks = async ( api: Api, @@ -21,7 +22,7 @@ export const useTasks = (params?: ScheduledTasksApiGetTasksRequest) => { const { api } = useApi(); return useQuery({ - queryKey: [ QueryKey.Tasks ], + queryKey: [ QUERY_KEY ], queryFn: ({ signal }) => fetchTasks(api!, params, { signal }), enabled: !!api diff --git a/src/apps/dashboard/features/tasks/api/useUpdateTask.ts b/src/apps/dashboard/features/tasks/api/useUpdateTask.ts index 4d3f7c87c0..dd0e8ac72b 100644 --- a/src/apps/dashboard/features/tasks/api/useUpdateTask.ts +++ b/src/apps/dashboard/features/tasks/api/useUpdateTask.ts @@ -3,7 +3,7 @@ import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-task import { useMutation } from '@tanstack/react-query'; import { useApi } from 'hooks/useApi'; import { queryClient } from 'utils/query/queryClient'; -import { QueryKey } from './queryKey'; +import { QUERY_KEY } from './useTasks'; export const useUpdateTask = () => { const { api } = useApi(); @@ -15,7 +15,7 @@ export const useUpdateTask = () => { ), onSuccess: (_data, params) => { void queryClient.invalidateQueries({ - queryKey: [ QueryKey.Task, params.taskId ] + queryKey: [ QUERY_KEY, params.taskId ] }); } }); diff --git a/src/apps/dashboard/routes/tasks/index.tsx b/src/apps/dashboard/routes/tasks/index.tsx index 7dd66224d4..232fb34950 100644 --- a/src/apps/dashboard/routes/tasks/index.tsx +++ b/src/apps/dashboard/routes/tasks/index.tsx @@ -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 { useTasks } from '../../features/tasks/api/useTasks'; +import { QUERY_KEY, 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,7 +14,6 @@ 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(); @@ -23,13 +22,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([ QueryKey.Tasks ], info); + queryClient.setQueryData([ QUERY_KEY ], info); }; const fallbackInterval = setInterval(() => { if (!__legacyApiClient__?.isMessageChannelOpen()) { void queryClient.invalidateQueries({ - queryKey: [ QueryKey.Tasks ] + queryKey: [ QUERY_KEY ] }); } }, 1e4);