2025-02-21 00:18:42 +03:00
|
|
|
import { ScheduledTasksApiStartTaskRequest } from '@jellyfin/sdk/lib/generated-client/api/scheduled-tasks-api';
|
|
|
|
import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-tasks-api';
|
|
|
|
import { useMutation } from '@tanstack/react-query';
|
|
|
|
import { useApi } from 'hooks/useApi';
|
|
|
|
import { queryClient } from 'utils/query/queryClient';
|
2025-02-23 17:38:31 +03:00
|
|
|
import { QueryKey } from './queryKey';
|
2025-02-21 00:18:42 +03:00
|
|
|
|
|
|
|
export const useStopTask = () => {
|
|
|
|
const { api } = useApi();
|
|
|
|
|
|
|
|
return useMutation({
|
|
|
|
mutationFn: (params: ScheduledTasksApiStartTaskRequest) => (
|
|
|
|
getScheduledTasksApi(api!)
|
|
|
|
.stopTask(params)
|
|
|
|
),
|
|
|
|
onSuccess: () => {
|
|
|
|
void queryClient.invalidateQueries({
|
2025-02-23 17:38:31 +03:00
|
|
|
queryKey: [ QueryKey.Tasks ]
|
2025-02-21 00:18:42 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|