From b378c46ab56788d83751a8ac6200fa4e4686a132 Mon Sep 17 00:00:00 2001 From: grafixeyehero Date: Mon, 9 Sep 2024 00:52:09 +0300 Subject: [PATCH] apply suggestion Co-authored-by: dmitrylyzo <56478732+dmitrylyzo@users.noreply.github.com> --- .../details/components/buttons/CancelSeriesTimerButton.tsx | 6 ++---- .../details/components/buttons/CancelTimerButton.tsx | 6 ++---- .../details/components/buttons/MoreCommandsButton.tsx | 6 ++---- .../details/components/buttons/PlayOrResumeButton.tsx | 2 +- .../features/details/components/buttons/ShuffleButton.tsx | 2 +- .../details/components/buttons/SplitVersionsButton.tsx | 7 +++---- .../features/details/hooks/api/useGetItemByType.ts | 6 ++---- src/strings/en-us.json | 3 +++ 8 files changed, 16 insertions(+), 22 deletions(-) diff --git a/src/apps/experimental/features/details/components/buttons/CancelSeriesTimerButton.tsx b/src/apps/experimental/features/details/components/buttons/CancelSeriesTimerButton.tsx index 7f3acd1678f1..f6593d0bee5d 100644 --- a/src/apps/experimental/features/details/components/buttons/CancelSeriesTimerButton.tsx +++ b/src/apps/experimental/features/details/components/buttons/CancelSeriesTimerButton.tsx @@ -39,10 +39,8 @@ const CancelSeriesTimerButton: FC = ({ navigate('/livetv.html'); }, onError: (err: unknown) => { - console.error( - '[cancelSeriesTimer] failed to cancel series timer', - err - ); + loading.hide(); + toast(globalize.translate('MessageCancelSeriesTimerError', err)); } } ); diff --git a/src/apps/experimental/features/details/components/buttons/CancelTimerButton.tsx b/src/apps/experimental/features/details/components/buttons/CancelTimerButton.tsx index 0687df7f5d8b..0807c6afc560 100644 --- a/src/apps/experimental/features/details/components/buttons/CancelTimerButton.tsx +++ b/src/apps/experimental/features/details/components/buttons/CancelTimerButton.tsx @@ -35,10 +35,8 @@ const CancelTimerButton: FC = ({ }, onError: (err: unknown) => { - console.error( - '[cancelTimer] failed to cancel timer', - err - ); + loading.hide(); + toast(globalize.translate('MessageCancelTimerError', err)); } } ); diff --git a/src/apps/experimental/features/details/components/buttons/MoreCommandsButton.tsx b/src/apps/experimental/features/details/components/buttons/MoreCommandsButton.tsx index e679f9e77297..e767712364a4 100644 --- a/src/apps/experimental/features/details/components/buttons/MoreCommandsButton.tsx +++ b/src/apps/experimental/features/details/components/buttons/MoreCommandsButton.tsx @@ -82,7 +82,6 @@ export interface ContextMenuOpts { } interface MoreCommandsButtonProps { - className?: string; itemType: ItemKind; selectedItemId?: string; itemId?: string; @@ -96,7 +95,6 @@ interface MoreCommandsButtonProps { } const MoreCommandsButton: FC = ({ - className, itemType, selectedItemId, itemId, @@ -112,7 +110,7 @@ const MoreCommandsButton: FC = ({ const queryClient = useQueryClient(); const { data: item } = useGetItemByType({ itemType, - itemId: selectedItemId || itemId + itemId: selectedItemId || itemId || '' }); const parentId = item?.SeasonId || item?.SeriesId || item?.ParentId; @@ -206,7 +204,7 @@ const MoreCommandsButton: FC = ({ ) { return ( diff --git a/src/apps/experimental/features/details/components/buttons/PlayOrResumeButton.tsx b/src/apps/experimental/features/details/components/buttons/PlayOrResumeButton.tsx index faed1104cc89..a52453656f4c 100644 --- a/src/apps/experimental/features/details/components/buttons/PlayOrResumeButton.tsx +++ b/src/apps/experimental/features/details/components/buttons/PlayOrResumeButton.tsx @@ -70,7 +70,7 @@ const PlayOrResumeButton: FC = ({ return ( = ({ item }) => { return ( diff --git a/src/apps/experimental/features/details/components/buttons/SplitVersionsButton.tsx b/src/apps/experimental/features/details/components/buttons/SplitVersionsButton.tsx index b7bb10169348..d731ea8a7392 100644 --- a/src/apps/experimental/features/details/components/buttons/SplitVersionsButton.tsx +++ b/src/apps/experimental/features/details/components/buttons/SplitVersionsButton.tsx @@ -6,6 +6,7 @@ import { useDeleteAlternateSources } from 'hooks/api/videosHooks'; import globalize from 'lib/globalize'; import confirm from 'components/confirm/confirm'; import loading from 'components/loading/loading'; +import toast from 'components/toast/toast'; interface SplitVersionsButtonProps { paramId: string; @@ -38,10 +39,8 @@ const SplitVersionsButton: FC = ({ }); }, onError: (err: unknown) => { - console.error( - '[splitVersions] failed to delete Videos', - err - ); + loading.hide(); + toast(globalize.translate('MessageSplitVersionsError', err)); } } ); diff --git a/src/apps/experimental/features/details/hooks/api/useGetItemByType.ts b/src/apps/experimental/features/details/hooks/api/useGetItemByType.ts index dc72771b403f..3cb2a9c716e9 100644 --- a/src/apps/experimental/features/details/hooks/api/useGetItemByType.ts +++ b/src/apps/experimental/features/details/hooks/api/useGetItemByType.ts @@ -4,19 +4,17 @@ import { getLiveTvApi } from '@jellyfin/sdk/lib/utils/api/live-tv-api'; import { useQuery } from '@tanstack/react-query'; import { type JellyfinApiContext, useApi } from 'hooks/useApi'; import type { ItemDto } from 'types/base/models/item-dto'; -import type{ NullableString } from 'types/base/common/shared/types'; import { ItemKind } from 'types/base/models/item-kind'; const getItemByType = async ( apiContext: JellyfinApiContext, itemType: ItemKind, - itemId: NullableString, + itemId: string, 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 (!itemId) throw new Error('No item ID provided'); let response; switch (itemType) { @@ -46,7 +44,7 @@ const getItemByType = async ( interface UseGetItemByTypeProps { itemType: ItemKind; - itemId: NullableString; + itemId: string; } export const useGetItemByType = ({ diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 560b469b9066..a6ecd0421e0a 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1045,6 +1045,9 @@ "MessageAreYouSureDeleteSubtitles": "Are you sure you wish to delete this subtitle file?", "MessageAreYouSureYouWishToRemoveMediaFolder": "Are you sure you wish to remove this media folder?", "MessageBrowsePluginCatalog": "Browse our plugin catalog to view available plugins.", + "MessageCancelSeriesTimerError": "An error occurred while cancel series timer {0}", + "MessageCancelTimerError": "An error occurred while cancel timer {0}", + "MessageSplitVersionsError": "An error occurred while split versions {0}", "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?", "MessageConfirmDeleteGuideProvider": "Are you sure you wish to delete this guide provider?",