1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Update search.tsx

This commit is contained in:
Brad Beattie 2023-10-19 10:23:52 -07:00 committed by Bill Thornton
parent ba099a0e3d
commit 45923c2e4d

View file

@ -22,9 +22,7 @@ const Search: FunctionComponent = () => {
const [ query, setQuery ] = useState<string>(searchParams.get('query') || ''); const [ query, setQuery ] = useState<string>(searchParams.get('query') || '');
const prevQuery = usePrevious(query); const prevQuery = usePrevious(query);
console.error('Search component initialized', { 'urlParam': searchParams.get('query'), 'obj.query': query, 'prevQuery': prevQuery });
if (query == prevQuery && searchParams.get('query') != query) { if (query == prevQuery && searchParams.get('query') != query) {
console.error('SET QUERY VIA URL', searchParams.get('query'));
setQuery(searchParams.get('query') || ''); setQuery(searchParams.get('query') || '');
} }
@ -34,7 +32,6 @@ const Search: FunctionComponent = () => {
/* Explicitly using `window.history.pushState` instead of `history.replace` as the use of the latter /* Explicitly using `window.history.pushState` instead of `history.replace` as the use of the latter
triggers a re-rendering of this component, resulting in double-execution searches. If there's a triggers a re-rendering of this component, resulting in double-execution searches. If there's a
way to use `history` without this side effect, it would likely be preferable. */ way to use `history` without this side effect, it would likely be preferable. */
console.error('PUSH STATE VIA QUERY', query);
window.history.pushState({}, '', `/#${history.location.pathname}${newSearch}`); window.history.pushState({}, '', `/#${history.location.pathname}${newSearch}`);
} }
}, [query, prevQuery]); }, [query, prevQuery]);