mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix bug with initial keystroke resulting in empty search
This commit is contained in:
parent
ad01e8669d
commit
d9aa7319be
3 changed files with 9 additions and 14 deletions
|
@ -9,7 +9,7 @@ import { MediaType } from '@jellyfin/sdk/lib/generated-client/models/media-type'
|
|||
import { BaseItemKind } from '@jellyfin/sdk/lib/generated-client/models/base-item-kind';
|
||||
import { ItemsApiGetItemsRequest } from '@jellyfin/sdk/lib/generated-client/api/items-api';
|
||||
|
||||
const fetchPeople = async (
|
||||
const fetchVideos = async (
|
||||
api: Api,
|
||||
userId: string,
|
||||
params?: ItemsApiGetItemsRequest,
|
||||
|
@ -43,7 +43,7 @@ export const useVideoSearch = (
|
|||
|
||||
return useQuery({
|
||||
queryKey: ['VideoSearch', collectionType, parentId, searchTerm],
|
||||
queryFn: ({ signal }) => fetchPeople(
|
||||
queryFn: ({ signal }) => fetchVideos(
|
||||
api!,
|
||||
userId!,
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useCallback, type FC } from 'react';
|
||||
import React, { type FC } from 'react';
|
||||
import { useSearchItems } from '../api/useSearchItems';
|
||||
import globalize from '../../../../../lib/globalize';
|
||||
import Loading from '../../../../../components/loading/LoadingComponent';
|
||||
|
@ -6,8 +6,7 @@ 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';
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
interface SearchResultsProps {
|
||||
parentId?: string;
|
||||
|
@ -24,13 +23,6 @@ const SearchResults: FC<SearchResultsProps> = ({
|
|||
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 <Loading />;
|
||||
|
||||
|
@ -40,7 +32,10 @@ const SearchResults: FC<SearchResultsProps> = ({
|
|||
{globalize.translate('SearchResultsEmpty', query)}
|
||||
{collectionType && (
|
||||
<div>
|
||||
<LinkButton href={getUri()}>{globalize.translate('RetryWithGlobalSearch')}</LinkButton>
|
||||
<Link
|
||||
className='emby-button'
|
||||
to={`/search.html?query=${encodeURIComponent(query || '')}`}
|
||||
>{globalize.translate('RetryWithGlobalSearch')}</Link>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
@ -51,7 +51,7 @@ const Search: FC = () => {
|
|||
className='mainAnimatedPage libraryPage allLibraryPage noSecondaryNavPage'
|
||||
>
|
||||
<SearchFields query={query} onSearch={setQuery} />
|
||||
{!query ? (
|
||||
{!debouncedQuery ? (
|
||||
<SearchSuggestions
|
||||
parentId={parentIdQuery}
|
||||
/>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue