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

Use react query to fetch syncplay groups

This commit is contained in:
Bill Thornton 2023-09-26 01:25:42 -04:00
parent 55a2ca3590
commit e46330c70d
2 changed files with 28 additions and 22 deletions

View file

@ -0,0 +1,24 @@
import { useQuery } from '@tanstack/react-query';
import { JellyfinApiContext, useApi } from './useApi';
import { getSyncPlayApi } from '@jellyfin/sdk/lib/utils/api/sync-play-api';
import { AxiosRequestConfig } from 'axios';
const fetchSyncPlayGroups = async (
currentApi: JellyfinApiContext,
options?: AxiosRequestConfig
) => {
const { api } = currentApi;
if (!api) throw new Error('No API instance available');
const response = await getSyncPlayApi(api)
.syncPlayGetGroups(options);
return response.data;
};
export const useSyncPlayGroups = () => {
const currentApi = useApi();
return useQuery({
queryKey: [ 'SyncPlay', 'Groups' ],
queryFn: ({ signal }) => fetchSyncPlayGroups(currentApi, { signal })
});
};