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
|
@ -13,8 +13,9 @@ const getItemByType = async (
|
||||||
options?: AxiosRequestConfig
|
options?: AxiosRequestConfig
|
||||||
) => {
|
) => {
|
||||||
const { api, user } = apiContext;
|
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('[getItemByType] No API instance available');
|
||||||
|
if (!user?.Id) throw new Error('[getItemByType] No User ID provided');
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
|
|
|
@ -10,29 +10,25 @@ const getDownload = async (
|
||||||
options?: AxiosRequestConfig
|
options?: AxiosRequestConfig
|
||||||
) => {
|
) => {
|
||||||
const { api, user } = apiContext;
|
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(
|
if (!api) throw new Error('[getDownload] No API instance available');
|
||||||
params,
|
if (!user?.Id) throw new Error('[getDownload] No User ID provided');
|
||||||
options
|
|
||||||
);
|
const response = await getLibraryApi(api).getDownload(params, options);
|
||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getDownloadQuery = (
|
export const getDownloadQuery = (
|
||||||
apiContext: JellyfinApiContext,
|
apiContext: JellyfinApiContext,
|
||||||
params: LibraryApiGetDownloadRequest
|
params: LibraryApiGetDownloadRequest
|
||||||
) => queryOptions({
|
) =>
|
||||||
queryKey: ['Download', params.itemId],
|
queryOptions({
|
||||||
queryFn: ({ signal }) =>
|
queryKey: ['Download', params.itemId],
|
||||||
getDownload(apiContext, params, { signal }),
|
queryFn: ({ signal }) => getDownload(apiContext, params, { signal }),
|
||||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.itemId
|
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.itemId
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useGetDownload = (
|
export const useGetDownload = (params: LibraryApiGetDownloadRequest) => {
|
||||||
params: LibraryApiGetDownloadRequest
|
|
||||||
) => {
|
|
||||||
const apiContext = useApi();
|
const apiContext = useApi();
|
||||||
return useQuery(getDownloadQuery(apiContext, params));
|
return useQuery(getDownloadQuery(apiContext, params));
|
||||||
};
|
};
|
||||||
|
|
|
@ -8,10 +8,11 @@ const cancelSeriesTimer = async (
|
||||||
params: LiveTvApiCancelSeriesTimerRequest
|
params: LiveTvApiCancelSeriesTimerRequest
|
||||||
) => {
|
) => {
|
||||||
const { api } = apiContext;
|
const { api } = apiContext;
|
||||||
if (api) {
|
|
||||||
const response = await getLiveTvApi(api).cancelSeriesTimer(params);
|
if (!api) throw new Error('[cancelSeriesTimer] No API instance available');
|
||||||
return response.data;
|
|
||||||
}
|
const response = await getLiveTvApi(api).cancelSeriesTimer(params);
|
||||||
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCancelSeriesTimer = () => {
|
export const useCancelSeriesTimer = () => {
|
||||||
|
|
|
@ -8,10 +8,11 @@ const cancelTimer = async (
|
||||||
params: LiveTvApiCancelTimerRequest
|
params: LiveTvApiCancelTimerRequest
|
||||||
) => {
|
) => {
|
||||||
const { api } = apiContext;
|
const { api } = apiContext;
|
||||||
if (api) {
|
|
||||||
const response = await getLiveTvApi(api).cancelTimer(params);
|
if (!api) throw new Error('[cancelTimer] No API instance available');
|
||||||
return response.data;
|
|
||||||
}
|
const response = await getLiveTvApi(api).cancelTimer(params);
|
||||||
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useCancelTimer = () => {
|
export const useCancelTimer = () => {
|
||||||
|
|
|
@ -10,8 +10,9 @@ const getChannel = async (
|
||||||
options?: AxiosRequestConfig
|
options?: AxiosRequestConfig
|
||||||
) => {
|
) => {
|
||||||
const { api, user } = apiContext;
|
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(
|
const response = await getLiveTvApi(api).getChannel(
|
||||||
{
|
{
|
||||||
|
@ -26,15 +27,15 @@ const getChannel = async (
|
||||||
export const getChannelQuery = (
|
export const getChannelQuery = (
|
||||||
apiContext: JellyfinApiContext,
|
apiContext: JellyfinApiContext,
|
||||||
params: LiveTvApiGetChannelRequest
|
params: LiveTvApiGetChannelRequest
|
||||||
) => queryOptions({
|
) =>
|
||||||
queryKey: ['Channel', params.channelId],
|
queryOptions({
|
||||||
queryFn: ({ signal }) => getChannel(apiContext, params, { signal }),
|
queryKey: ['Channel', params.channelId],
|
||||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.channelId
|
queryFn: ({ signal }) => getChannel(apiContext, params, { signal }),
|
||||||
});
|
enabled:
|
||||||
|
!!apiContext.api && !!apiContext.user?.Id && !!params.channelId
|
||||||
|
});
|
||||||
|
|
||||||
export const useGetChannel = (
|
export const useGetChannel = (params: LiveTvApiGetChannelRequest) => {
|
||||||
params: LiveTvApiGetChannelRequest
|
|
||||||
) => {
|
|
||||||
const apiContext = useApi();
|
const apiContext = useApi();
|
||||||
return useQuery(getChannelQuery(apiContext, params));
|
return useQuery(getChannelQuery(apiContext, params));
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,25 +10,26 @@ const getSeriesTimer = async (
|
||||||
options?: AxiosRequestConfig
|
options?: AxiosRequestConfig
|
||||||
) => {
|
) => {
|
||||||
const { api } = apiContext;
|
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;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getSeriesTimerQuery = (
|
export const getSeriesTimerQuery = (
|
||||||
apiContext: JellyfinApiContext,
|
apiContext: JellyfinApiContext,
|
||||||
params: LiveTvApiGetSeriesTimerRequest
|
params: LiveTvApiGetSeriesTimerRequest
|
||||||
) => queryOptions({
|
) =>
|
||||||
queryKey: ['SeriesTimer', params.timerId],
|
queryOptions({
|
||||||
queryFn: ({ signal }) => getSeriesTimer(apiContext, params, { signal }),
|
queryKey: ['SeriesTimer', params.timerId],
|
||||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!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();
|
const apiContext = useApi();
|
||||||
return useQuery(getSeriesTimerQuery(apiContext, requestParameters));
|
return useQuery(getSeriesTimerQuery(apiContext, requestParameters));
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,23 +10,22 @@ const getTimer = async (
|
||||||
options?: AxiosRequestConfig
|
options?: AxiosRequestConfig
|
||||||
) => {
|
) => {
|
||||||
const { api } = currentApi;
|
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;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getTimerQuery = (
|
export const getTimerQuery = (
|
||||||
apiContext: JellyfinApiContext,
|
apiContext: JellyfinApiContext,
|
||||||
params: LiveTvApiGetTimerRequest
|
params: LiveTvApiGetTimerRequest
|
||||||
) => queryOptions({
|
) =>
|
||||||
queryKey: ['Timer', params.timerId],
|
queryOptions({
|
||||||
queryFn: ({ signal }) => getTimer(apiContext, params, { signal }),
|
queryKey: ['Timer', params.timerId],
|
||||||
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
queryFn: ({ signal }) => getTimer(apiContext, params, { signal }),
|
||||||
});
|
enabled: !!apiContext.api && !!apiContext.user?.Id && !!params.timerId
|
||||||
|
});
|
||||||
|
|
||||||
export const useGetTimer = (requestParameters: LiveTvApiGetTimerRequest) => {
|
export const useGetTimer = (requestParameters: LiveTvApiGetTimerRequest) => {
|
||||||
const apiContext = useApi();
|
const apiContext = useApi();
|
||||||
|
|
|
@ -8,10 +8,11 @@ const deleteAlternateSources = async (
|
||||||
params: VideosApiDeleteAlternateSourcesRequest
|
params: VideosApiDeleteAlternateSourcesRequest
|
||||||
) => {
|
) => {
|
||||||
const { api } = apiContext;
|
const { api } = apiContext;
|
||||||
if (api) {
|
|
||||||
const response = await getVideosApi(api).deleteAlternateSources(params);
|
if (!api) throw new Error('[deleteAlternateSources] No API instance available');
|
||||||
return response.data;
|
|
||||||
}
|
const response = await getVideosApi(api).deleteAlternateSources(params);
|
||||||
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useDeleteAlternateSources = () => {
|
export const useDeleteAlternateSources = () => {
|
||||||
|
|
|
@ -1045,8 +1045,8 @@
|
||||||
"MessageAreYouSureDeleteSubtitles": "Are you sure you wish to delete this subtitle file?",
|
"MessageAreYouSureDeleteSubtitles": "Are you sure you wish to delete this subtitle file?",
|
||||||
"MessageAreYouSureYouWishToRemoveMediaFolder": "Are you sure you wish to remove this media folder?",
|
"MessageAreYouSureYouWishToRemoveMediaFolder": "Are you sure you wish to remove this media folder?",
|
||||||
"MessageBrowsePluginCatalog": "Browse our plugin catalog to view available plugins.",
|
"MessageBrowsePluginCatalog": "Browse our plugin catalog to view available plugins.",
|
||||||
"MessageCancelSeriesTimerError": "An error occurred while cancel series timer",
|
"MessageCancelSeriesTimerError": "An error occurred while canceling the series timer",
|
||||||
"MessageCancelTimerError": "An error occurred while cancel timer",
|
"MessageCancelTimerError": "An error occurred while canceling the timer",
|
||||||
"MessageChangeRecordingPath": "Changing your recording folder will not migrate existing recordings from the old location to the new. You'll need to move them manually if desired.",
|
"MessageChangeRecordingPath": "Changing your recording folder will not migrate existing recordings from the old location to the new. You'll need to move them manually if desired.",
|
||||||
"MessageConfirmAppExit": "Do you want to exit?",
|
"MessageConfirmAppExit": "Do you want to exit?",
|
||||||
"MessageConfirmDeleteGuideProvider": "Are you sure you wish to delete this guide provider?",
|
"MessageConfirmDeleteGuideProvider": "Are you sure you wish to delete this guide provider?",
|
||||||
|
@ -1099,7 +1099,7 @@
|
||||||
"MessageRenameMediaFolder": "Renaming a media library will cause all metadata to be lost, proceed with caution.",
|
"MessageRenameMediaFolder": "Renaming a media library will cause all metadata to be lost, proceed with caution.",
|
||||||
"MessageRepositoryInstallDisclaimer": "WARNING: Installing a third party plugin repository carries risks. It may contain unstable or malicious code, and may change at any time. Only install repositories from authors that you trust.",
|
"MessageRepositoryInstallDisclaimer": "WARNING: Installing a third party plugin repository carries risks. It may contain unstable or malicious code, and may change at any time. Only install repositories from authors that you trust.",
|
||||||
"MessageSent": "Message sent.",
|
"MessageSent": "Message sent.",
|
||||||
"MessageSplitVersionsError": "An error occurred while split versions",
|
"MessageSplitVersionsError": "An error occurred while splitting versions",
|
||||||
"MessageSyncPlayCreateGroupDenied": "Permission required to create a group.",
|
"MessageSyncPlayCreateGroupDenied": "Permission required to create a group.",
|
||||||
"MessageSyncPlayDisabled": "SyncPlay disabled.",
|
"MessageSyncPlayDisabled": "SyncPlay disabled.",
|
||||||
"MessageSyncPlayEnabled": "SyncPlay enabled.",
|
"MessageSyncPlayEnabled": "SyncPlay enabled.",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue