-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6565 from viown/react-tasks-edit
Migrate tasks edit page to react
- Loading branch information
Showing
22 changed files
with
530 additions
and
343 deletions.
There are no files selected for viewing
84 changes: 0 additions & 84 deletions
84
src/apps/dashboard/controllers/scheduledtasks/scheduledtask.html
This file was deleted.
Oops, something went wrong.
236 changes: 0 additions & 236 deletions
236
src/apps/dashboard/controllers/scheduledtasks/scheduledtask.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import type { ScheduledTasksApiGetTaskRequest } from '@jellyfin/sdk/lib/generated-client/api/scheduled-tasks-api'; | ||
import type { AxiosRequestConfig } from 'axios'; | ||
import type { Api } from '@jellyfin/sdk'; | ||
import { getScheduledTasksApi } from '@jellyfin/sdk/lib/utils/api/scheduled-tasks-api'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
import { useApi } from 'hooks/useApi'; | ||
import { QUERY_KEY } from './useTasks'; | ||
|
||
const fetchTask = async ( | ||
api: Api, | ||
params: ScheduledTasksApiGetTaskRequest, | ||
options?: AxiosRequestConfig | ||
) => { | ||
const response = await getScheduledTasksApi(api).getTask(params, options); | ||
|
||
return response.data; | ||
}; | ||
|
||
export const useTask = (params: ScheduledTasksApiGetTaskRequest) => { | ||
const { api } = useApi(); | ||
|
||
return useQuery({ | ||
queryKey: [ QUERY_KEY, params.taskId ], | ||
queryFn: ({ signal }) => | ||
fetchTask(api!, params, { signal }), | ||
enabled: !!api | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ScheduledTasksApiUpdateTaskRequest } 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 useUpdateTask = () => { | ||
const { api } = useApi(); | ||
|
||
return useMutation({ | ||
mutationFn: (params: ScheduledTasksApiUpdateTaskRequest) => ( | ||
getScheduledTasksApi(api!) | ||
.updateTask(params) | ||
), | ||
onSuccess: (_data, params) => { | ||
void queryClient.invalidateQueries({ | ||
queryKey: [ QUERY_KEY, params.taskId ] | ||
}); | ||
} | ||
}); | ||
}; |
Oops, something went wrong.