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

* Migrate scheduled tasks to React * Adjust margins * Use localeCompare * Clean up imports * Use legacy apiclient from useApi * Fix import * Fix nested typography * Add polling fallback * Cleanup code * Rename to tasks * Rename to Component * Use constants for websocket events * Use memo to fix timestamp rerender on run
23 lines
866 B
TypeScript
23 lines
866 B
TypeScript
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';
|
|
import { QUERY_KEY } from './useTasks';
|
|
|
|
export const useStopTask = () => {
|
|
const { api } = useApi();
|
|
|
|
return useMutation({
|
|
mutationFn: (params: ScheduledTasksApiStartTaskRequest) => (
|
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
getScheduledTasksApi(api!)
|
|
.stopTask(params)
|
|
),
|
|
onSuccess: () => {
|
|
void queryClient.invalidateQueries({
|
|
queryKey: [ QUERY_KEY ]
|
|
});
|
|
}
|
|
});
|
|
};
|