mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add check for quick connect enabled in menu
This commit is contained in:
parent
e7120061f8
commit
cfde45abee
2 changed files with 41 additions and 12 deletions
25
src/hooks/useQuickConnect.ts
Normal file
25
src/hooks/useQuickConnect.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { getQuickConnectApi } from '@jellyfin/sdk/lib/utils/api/quick-connect-api';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
|
||||
import { 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 })
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue