mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Add retry global search link button
This commit is contained in:
parent
1fd314213a
commit
ad01e8669d
4 changed files with 18 additions and 5 deletions
|
@ -33,7 +33,7 @@ export const useSearchItems = (
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ['SearchItems', collectionType, parentId, searchTerm],
|
queryKey: ['SearchItems', collectionType, parentId, searchTerm],
|
||||||
queryFn: async ({ signal }) => {
|
queryFn: async ({ signal }) => {
|
||||||
if (liveTvSections) {
|
if (liveTvSections && collectionType && isLivetv(collectionType)) {
|
||||||
return sortSections(liveTvSections);
|
return sortSections(liveTvSections);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import React, { type FC } from 'react';
|
import React, { useCallback, type FC } from 'react';
|
||||||
import { useSearchItems } from '../api/useSearchItems';
|
import { useSearchItems } from '../api/useSearchItems';
|
||||||
import globalize from '../../../../../lib/globalize';
|
import globalize from '../../../../../lib/globalize';
|
||||||
import Loading from '../../../../../components/loading/LoadingComponent';
|
import Loading from '../../../../../components/loading/LoadingComponent';
|
||||||
|
@ -6,6 +6,8 @@ import SearchResultsRow from './SearchResultsRow';
|
||||||
import { CardShape } from 'utils/card';
|
import { CardShape } from 'utils/card';
|
||||||
import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type';
|
import { CollectionType } from '@jellyfin/sdk/lib/generated-client/models/collection-type';
|
||||||
import { Section } from '../types';
|
import { Section } from '../types';
|
||||||
|
import LinkButton from 'elements/emby-button/LinkButton';
|
||||||
|
import { useLocation, useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
interface SearchResultsProps {
|
interface SearchResultsProps {
|
||||||
parentId?: string;
|
parentId?: string;
|
||||||
|
@ -22,6 +24,13 @@ const SearchResults: FC<SearchResultsProps> = ({
|
||||||
query
|
query
|
||||||
}) => {
|
}) => {
|
||||||
const { data, isPending } = useSearchItems(parentId, collectionType, query?.trim());
|
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 <Loading />;
|
if (isPending) return <Loading />;
|
||||||
|
|
||||||
|
@ -29,6 +38,11 @@ const SearchResults: FC<SearchResultsProps> = ({
|
||||||
return (
|
return (
|
||||||
<div className='noItemsMessage centerMessage'>
|
<div className='noItemsMessage centerMessage'>
|
||||||
{globalize.translate('SearchResultsEmpty', query)}
|
{globalize.translate('SearchResultsEmpty', query)}
|
||||||
|
{collectionType && (
|
||||||
|
<div>
|
||||||
|
<LinkButton href={getUri()}>{globalize.translate('RetryWithGlobalSearch')}</LinkButton>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ export function getTitleFromType(type: BaseItemKind) {
|
||||||
export function getItemTypesFromCollectionType(collectionType: CollectionType | undefined) {
|
export function getItemTypesFromCollectionType(collectionType: CollectionType | undefined) {
|
||||||
switch (collectionType) {
|
switch (collectionType) {
|
||||||
case CollectionType.Movies:
|
case CollectionType.Movies:
|
||||||
return [BaseItemKind.Movie];
|
return [ BaseItemKind.Movie ];
|
||||||
case CollectionType.Tvshows:
|
case CollectionType.Tvshows:
|
||||||
return [
|
return [
|
||||||
BaseItemKind.Series,
|
BaseItemKind.Series,
|
||||||
|
@ -122,8 +122,6 @@ export function getItemTypesFromCollectionType(collectionType: CollectionType |
|
||||||
BaseItemKind.MusicAlbum,
|
BaseItemKind.MusicAlbum,
|
||||||
BaseItemKind.Audio
|
BaseItemKind.Audio
|
||||||
];
|
];
|
||||||
case CollectionType.Livetv:
|
|
||||||
return [];
|
|
||||||
default:
|
default:
|
||||||
return [
|
return [
|
||||||
BaseItemKind.Movie,
|
BaseItemKind.Movie,
|
||||||
|
|
|
@ -1451,6 +1451,7 @@
|
||||||
"ReplaceExistingImages": "Replace existing images",
|
"ReplaceExistingImages": "Replace existing images",
|
||||||
"ReplaceTrickplayImages": "Replace existing trickplay images",
|
"ReplaceTrickplayImages": "Replace existing trickplay images",
|
||||||
"Retry": "Retry",
|
"Retry": "Retry",
|
||||||
|
"RetryWithGlobalSearch": "Retry with global search",
|
||||||
"Reset": "Reset",
|
"Reset": "Reset",
|
||||||
"ResetPassword": "Reset Password",
|
"ResetPassword": "Reset Password",
|
||||||
"ResolutionMatchSource": "Match Source",
|
"ResolutionMatchSource": "Match Source",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue