From ad01e8669d02982b9030aa7ad1e277533d4f77d5 Mon Sep 17 00:00:00 2001 From: viown <48097677+viown@users.noreply.github.com> Date: Thu, 6 Mar 2025 13:14:35 +0300 Subject: [PATCH] Add retry global search link button --- .../stable/features/search/api/useSearchItems.ts | 2 +- .../features/search/components/SearchResults.tsx | 16 +++++++++++++++- src/apps/stable/features/search/utils/search.ts | 4 +--- src/strings/en-us.json | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/apps/stable/features/search/api/useSearchItems.ts b/src/apps/stable/features/search/api/useSearchItems.ts index cb0a815373..f36be74dfd 100644 --- a/src/apps/stable/features/search/api/useSearchItems.ts +++ b/src/apps/stable/features/search/api/useSearchItems.ts @@ -33,7 +33,7 @@ export const useSearchItems = ( return useQuery({ queryKey: ['SearchItems', collectionType, parentId, searchTerm], queryFn: async ({ signal }) => { - if (liveTvSections) { + if (liveTvSections && collectionType && isLivetv(collectionType)) { return sortSections(liveTvSections); } diff --git a/src/apps/stable/features/search/components/SearchResults.tsx b/src/apps/stable/features/search/components/SearchResults.tsx index 97d23a9c4a..8b76b5cbc0 100644 --- a/src/apps/stable/features/search/components/SearchResults.tsx +++ b/src/apps/stable/features/search/components/SearchResults.tsx @@ -1,4 +1,4 @@ -import React, { type FC } from 'react'; +import React, { useCallback, type FC } from 'react'; import { useSearchItems } from '../api/useSearchItems'; import globalize from '../../../../../lib/globalize'; import Loading from '../../../../../components/loading/LoadingComponent'; @@ -6,6 +6,8 @@ import SearchResultsRow from './SearchResultsRow'; import { CardShape } from 'utils/card'; import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type'; import { Section } from '../types'; +import LinkButton from 'elements/emby-button/LinkButton'; +import { useLocation, useSearchParams } from 'react-router-dom'; interface SearchResultsProps { parentId?: string; @@ -22,6 +24,13 @@ const SearchResults: FC = ({ query }) => { const { data, isPending } = useSearchItems(parentId, collectionType, query?.trim()); + const location = useLocation(); + const [ searchParams ] = useSearchParams(); + + const getUri = useCallback(() => { + searchParams.delete('collectionType'); + return `${location.pathname}?${searchParams.toString()}`; + }, [ searchParams, location.pathname ]); if (isPending) return ; @@ -29,6 +38,11 @@ const SearchResults: FC = ({ return (
{globalize.translate('SearchResultsEmpty', query)} + {collectionType && ( +
+ {globalize.translate('RetryWithGlobalSearch')} +
+ )}
); } diff --git a/src/apps/stable/features/search/utils/search.ts b/src/apps/stable/features/search/utils/search.ts index ec06b099d9..6de5138cd7 100644 --- a/src/apps/stable/features/search/utils/search.ts +++ b/src/apps/stable/features/search/utils/search.ts @@ -110,7 +110,7 @@ export function getTitleFromType(type: BaseItemKind) { export function getItemTypesFromCollectionType(collectionType: CollectionType | undefined) { switch (collectionType) { case CollectionType.Movies: - return [BaseItemKind.Movie]; + return [ BaseItemKind.Movie ]; case CollectionType.Tvshows: return [ BaseItemKind.Series, @@ -122,8 +122,6 @@ export function getItemTypesFromCollectionType(collectionType: CollectionType | BaseItemKind.MusicAlbum, BaseItemKind.Audio ]; - case CollectionType.Livetv: - return []; default: return [ BaseItemKind.Movie, diff --git a/src/strings/en-us.json b/src/strings/en-us.json index 0204b9817d..02b856225c 100644 --- a/src/strings/en-us.json +++ b/src/strings/en-us.json @@ -1451,6 +1451,7 @@ "ReplaceExistingImages": "Replace existing images", "ReplaceTrickplayImages": "Replace existing trickplay images", "Retry": "Retry", + "RetryWithGlobalSearch": "Retry with global search", "Reset": "Reset", "ResetPassword": "Reset Password", "ResolutionMatchSource": "Match Source",