mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Merge branch 'master' into trickplay-new
This commit is contained in:
commit
7f7c1be5e1
44 changed files with 548 additions and 277 deletions
|
@ -3,15 +3,13 @@ import ListItemIcon from '@mui/material/ListItemIcon';
|
|||
import ListItemText from '@mui/material/ListItemText';
|
||||
import React from 'react';
|
||||
|
||||
import { useApi } from 'hooks/useApi';
|
||||
import { useSystemInfo } from 'hooks/useSystemInfo';
|
||||
import ListItemLink from 'components/ListItemLink';
|
||||
|
||||
import appIcon from 'assets/img/icon-transparent.png';
|
||||
|
||||
const DrawerHeaderLink = () => {
|
||||
const { api } = useApi();
|
||||
const { data: systemInfo } = useSystemInfo(api);
|
||||
const { data: systemInfo } = useSystemInfo();
|
||||
|
||||
return (
|
||||
<ListItemLink to='/'>
|
||||
|
|
|
@ -1,16 +1,46 @@
|
|||
import React, { FunctionComponent, useState } from 'react';
|
||||
import React, { type FC, useEffect, useState } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
|
||||
import Page from '../../../components/Page';
|
||||
import SearchFields from '../../../components/search/SearchFields';
|
||||
import SearchResults from '../../../components/search/SearchResults';
|
||||
import SearchSuggestions from '../../../components/search/SearchSuggestions';
|
||||
import LiveTVSearchResults from '../../../components/search/LiveTVSearchResults';
|
||||
import globalize from '../../../scripts/globalize';
|
||||
import Page from 'components/Page';
|
||||
import SearchFields from 'components/search/SearchFields';
|
||||
import SearchResults from 'components/search/SearchResults';
|
||||
import SearchSuggestions from 'components/search/SearchSuggestions';
|
||||
import LiveTVSearchResults from 'components/search/LiveTVSearchResults';
|
||||
import { usePrevious } from 'hooks/usePrevious';
|
||||
import globalize from 'scripts/globalize';
|
||||
|
||||
const Search: FunctionComponent = () => {
|
||||
const [ query, setQuery ] = useState<string>();
|
||||
const [ searchParams ] = useSearchParams();
|
||||
const COLLECTION_TYPE_PARAM = 'collectionType';
|
||||
const PARENT_ID_PARAM = 'parentId';
|
||||
const QUERY_PARAM = 'query';
|
||||
const SERVER_ID_PARAM = 'serverId';
|
||||
|
||||
const Search: FC = () => {
|
||||
const [ searchParams, setSearchParams ] = useSearchParams();
|
||||
const urlQuery = searchParams.get(QUERY_PARAM) || '';
|
||||
const [ query, setQuery ] = useState(urlQuery);
|
||||
const prevQuery = usePrevious(query, '');
|
||||
|
||||
useEffect(() => {
|
||||
if (query !== prevQuery) {
|
||||
if (query === '' && urlQuery !== '') {
|
||||
// The query input has been cleared; remove the url param
|
||||
searchParams.delete(QUERY_PARAM);
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
} else if (query !== urlQuery) {
|
||||
// Update the query url param value
|
||||
searchParams.set(QUERY_PARAM, query);
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
}
|
||||
} else if (query !== urlQuery) {
|
||||
// Update the query if the query url param has changed
|
||||
if (!urlQuery) {
|
||||
searchParams.delete(QUERY_PARAM);
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
}
|
||||
|
||||
setQuery(urlQuery);
|
||||
}
|
||||
}, [query, prevQuery, searchParams, setSearchParams, urlQuery]);
|
||||
|
||||
return (
|
||||
<Page
|
||||
|
@ -18,22 +48,22 @@ const Search: FunctionComponent = () => {
|
|||
title={globalize.translate('Search')}
|
||||
className='mainAnimatedPage libraryPage allLibraryPage noSecondaryNavPage'
|
||||
>
|
||||
<SearchFields onSearch={setQuery} />
|
||||
<SearchFields query={query} onSearch={setQuery} />
|
||||
{!query
|
||||
&& <SearchSuggestions
|
||||
parentId={searchParams.get('parentId')}
|
||||
parentId={searchParams.get(PARENT_ID_PARAM)}
|
||||
/>
|
||||
}
|
||||
<SearchResults
|
||||
serverId={searchParams.get('serverId') || window.ApiClient.serverId()}
|
||||
parentId={searchParams.get('parentId')}
|
||||
collectionType={searchParams.get('collectionType')}
|
||||
serverId={searchParams.get(SERVER_ID_PARAM) || window.ApiClient.serverId()}
|
||||
parentId={searchParams.get(PARENT_ID_PARAM)}
|
||||
collectionType={searchParams.get(COLLECTION_TYPE_PARAM)}
|
||||
query={query}
|
||||
/>
|
||||
<LiveTVSearchResults
|
||||
serverId={searchParams.get('serverId') || window.ApiClient.serverId()}
|
||||
parentId={searchParams.get('parentId')}
|
||||
collectionType={searchParams.get('collectionType')}
|
||||
serverId={searchParams.get(SERVER_ID_PARAM) || window.ApiClient.serverId()}
|
||||
parentId={searchParams.get(PARENT_ID_PARAM)}
|
||||
collectionType={searchParams.get(COLLECTION_TYPE_PARAM)}
|
||||
query={query}
|
||||
/>
|
||||
</Page>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue