mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
25 lines
821 B
TypeScript
25 lines
821 B
TypeScript
import { getQuickConnectApi } from '@jellyfin/sdk/lib/utils/api/quick-connect-api';
|
|
import { useQuery } from '@tanstack/react-query';
|
|
import type { AxiosRequestConfig } from 'axios';
|
|
|
|
import { type JellyfinApiContext, useApi } from './useApi';
|
|
|
|
const fetchQuickConnectEnabled = async (
|
|
apiContext: JellyfinApiContext,
|
|
options?: AxiosRequestConfig
|
|
) => {
|
|
const { api } = apiContext;
|
|
if (!api) throw new Error('No API instance available');
|
|
|
|
const response = await getQuickConnectApi(api)
|
|
.getQuickConnectEnabled(options);
|
|
return response.data;
|
|
};
|
|
|
|
export const useQuickConnectEnabled = () => {
|
|
const currentApi = useApi();
|
|
return useQuery({
|
|
queryKey: [ 'QuickConnect', 'Enabled' ],
|
|
queryFn: ({ signal }) => fetchQuickConnectEnabled(currentApi, { signal })
|
|
});
|
|
};
|