mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
apply suggestion
Co-authored-by: Bill Thornton <thornbill@users.noreply.github.com>
This commit is contained in:
parent
1c18fa8fb2
commit
c5bbd5bca9
9 changed files with 64 additions and 63 deletions
|
@ -10,29 +10,25 @@ const getDownload = async (
|
|||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
const { api, user } = apiContext;
|
||||
if (!api) throw new Error('No API instance available');
|
||||
if (!user?.Id) throw new Error('No User ID provided');
|
||||
|
||||
const response = await getLibraryApi(api).getDownload(
|
||||
params,
|
||||
options
|
||||
);
|
||||
if (!api) throw new Error('[getDownload] No API instance available');
|
||||
if (!user?.Id) throw new Error('[getDownload] No User ID provided');
|
||||
|
||||
const response = await getLibraryApi(api).getDownload(params, options);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getDownloadQuery = (
|
||||
apiContext: JellyfinApiContext,
|
||||
params: LibraryApiGetDownloadRequest
|
||||
) => queryOptions({
|
||||
queryKey: ['Download', params.itemId],
|
||||
queryFn: ({ signal }) =>
|
||||
getDownload(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.itemId
|
||||
});
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ['Download', params.itemId],
|
||||
queryFn: ({ signal }) => getDownload(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.itemId
|
||||
});
|
||||
|
||||
export const useGetDownload = (
|
||||
params: LibraryApiGetDownloadRequest
|
||||
) => {
|
||||
export const useGetDownload = (params: LibraryApiGetDownloadRequest) => {
|
||||
const apiContext = useApi();
|
||||
return useQuery(getDownloadQuery(apiContext, params));
|
||||
};
|
||||
|
|
|
@ -8,10 +8,11 @@ const cancelSeriesTimer = async (
|
|||
params: LiveTvApiCancelSeriesTimerRequest
|
||||
) => {
|
||||
const { api } = apiContext;
|
||||
if (api) {
|
||||
const response = await getLiveTvApi(api).cancelSeriesTimer(params);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
if (!api) throw new Error('[cancelSeriesTimer] No API instance available');
|
||||
|
||||
const response = await getLiveTvApi(api).cancelSeriesTimer(params);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useCancelSeriesTimer = () => {
|
||||
|
|
|
@ -8,10 +8,11 @@ const cancelTimer = async (
|
|||
params: LiveTvApiCancelTimerRequest
|
||||
) => {
|
||||
const { api } = apiContext;
|
||||
if (api) {
|
||||
const response = await getLiveTvApi(api).cancelTimer(params);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
if (!api) throw new Error('[cancelTimer] No API instance available');
|
||||
|
||||
const response = await getLiveTvApi(api).cancelTimer(params);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useCancelTimer = () => {
|
||||
|
|
|
@ -10,8 +10,9 @@ const getChannel = async (
|
|||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
const { api, user } = apiContext;
|
||||
if (!api) throw new Error('No API instance available');
|
||||
if (!user?.Id) throw new Error('No User ID provided');
|
||||
|
||||
if (!api) throw new Error('[getChannel] No API instance available');
|
||||
if (!user?.Id) throw new Error('[getChannel] No User ID provided');
|
||||
|
||||
const response = await getLiveTvApi(api).getChannel(
|
||||
{
|
||||
|
@ -26,15 +27,15 @@ const getChannel = async (
|
|||
export const getChannelQuery = (
|
||||
apiContext: JellyfinApiContext,
|
||||
params: LiveTvApiGetChannelRequest
|
||||
) => queryOptions({
|
||||
queryKey: ['Channel', params.channelId],
|
||||
queryFn: ({ signal }) => getChannel(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.channelId
|
||||
});
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ['Channel', params.channelId],
|
||||
queryFn: ({ signal }) => getChannel(apiContext, params, { signal }),
|
||||
enabled:
|
||||
!!apiContext.api && !!apiContext.user?.Id && !!params.channelId
|
||||
});
|
||||
|
||||
export const useGetChannel = (
|
||||
params: LiveTvApiGetChannelRequest
|
||||
) => {
|
||||
export const useGetChannel = (params: LiveTvApiGetChannelRequest) => {
|
||||
const apiContext = useApi();
|
||||
return useQuery(getChannelQuery(apiContext, params));
|
||||
};
|
||||
|
|
|
@ -10,25 +10,26 @@ const getSeriesTimer = async (
|
|||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
const { api } = apiContext;
|
||||
if (!api) throw new Error('No API instance available');
|
||||
const response = await getLiveTvApi(api).getSeriesTimer(
|
||||
params,
|
||||
options
|
||||
);
|
||||
|
||||
if (!api) throw new Error('[getSeriesTimer] No API instance available');
|
||||
|
||||
const response = await getLiveTvApi(api).getSeriesTimer(params, options);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getSeriesTimerQuery = (
|
||||
apiContext: JellyfinApiContext,
|
||||
params: LiveTvApiGetSeriesTimerRequest
|
||||
) => queryOptions({
|
||||
queryKey: ['SeriesTimer', params.timerId],
|
||||
queryFn: ({ signal }) => getSeriesTimer(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
||||
});
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ['SeriesTimer', params.timerId],
|
||||
queryFn: ({ signal }) => getSeriesTimer(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
||||
});
|
||||
|
||||
export const useGetSeriesTimer = (requestParameters: LiveTvApiGetSeriesTimerRequest) => {
|
||||
export const useGetSeriesTimer = (
|
||||
requestParameters: LiveTvApiGetSeriesTimerRequest
|
||||
) => {
|
||||
const apiContext = useApi();
|
||||
return useQuery(getSeriesTimerQuery(apiContext, requestParameters));
|
||||
};
|
||||
|
|
|
@ -10,23 +10,22 @@ const getTimer = async (
|
|||
options?: AxiosRequestConfig
|
||||
) => {
|
||||
const { api } = currentApi;
|
||||
if (!api) throw new Error('No API instance available');
|
||||
const response = await getLiveTvApi(api).getTimer(
|
||||
params,
|
||||
options
|
||||
);
|
||||
|
||||
if (!api) throw new Error('[getTimer] No API instance available');
|
||||
|
||||
const response = await getLiveTvApi(api).getTimer(params, options);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const getTimerQuery = (
|
||||
apiContext: JellyfinApiContext,
|
||||
params: LiveTvApiGetTimerRequest
|
||||
) => queryOptions({
|
||||
queryKey: ['Timer', params.timerId],
|
||||
queryFn: ({ signal }) => getTimer(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
||||
});
|
||||
) =>
|
||||
queryOptions({
|
||||
queryKey: ['Timer', params.timerId],
|
||||
queryFn: ({ signal }) => getTimer(apiContext, params, { signal }),
|
||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
||||
});
|
||||
|
||||
export const useGetTimer = (requestParameters: LiveTvApiGetTimerRequest) => {
|
||||
const apiContext = useApi();
|
||||
|
|
|
@ -8,10 +8,11 @@ const deleteAlternateSources = async (
|
|||
params: VideosApiDeleteAlternateSourcesRequest
|
||||
) => {
|
||||
const { api } = apiContext;
|
||||
if (api) {
|
||||
const response = await getVideosApi(api).deleteAlternateSources(params);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
if (!api) throw new Error('[deleteAlternateSources] No API instance available');
|
||||
|
||||
const response = await getVideosApi(api).deleteAlternateSources(params);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export const useDeleteAlternateSources = () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue