feat(search): unified movie+series search, results ranked by rating

This commit is contained in:
ner committed 2026-10-23 21:01:35 +03:00
1 parent 75880e5ac7
commit 6cff846f94
4 files changed
+22 -13

No files matched your search

@@ -3,7 +3,6 @@
import { ChangeEvent, MutableRefObject, useRef, useState } from 'react';
import { create } from 'react-modal-promise';
import { Search as SearchIcon, X } from 'lucide-react';
import { usePathname } from 'next/navigation';
import List from '@/components/List';
import { Button } from '@/components/ui/button';
@@ -11,7 +10,6 @@ import ButtonsGroup from '@/components/ui/buttons-group';
import { Modal } from '@/components/ui/dialog';
import { Input } from '@/components/ui/input';
import useDistinctUntilChanged from '@/hooks/useDistinctUntilChanged';
import { showTypeFromPath } from '@/lib/showType';
import useSearch from './useSearch';
@@ -20,13 +18,12 @@ export const showSearchModal = create(({ onResolve }) => {
const scrollRef = useRef<HTMLDivElement>(null) as MutableRefObject<HTMLDivElement>;
const inputRef = useRef<HTMLInputElement>(null);
const isFetchedRef = useRef(false);
const showType = showTypeFromPath(usePathname());
const query = useDistinctUntilChanged(title);
const settledTitle = useDistinctUntilChanged(title, 1000);
const settled = title === settledTitle;
const search = useSearch({ query, type: showType, settled });
const search = useSearch({ query, settled });
const handleChangeTitle = ({ target: { value } }: ChangeEvent<HTMLInputElement>) => setTitle(value);
@@ -12,8 +12,8 @@ const useSearch = (props: SearchQueryProps & { settled: boolean }) => {
useTrackOnce(
analytics.searchPerformed,
props.query && props.settled && infiniteQuery.isFetched ? `${props.type}:${props.query}` : undefined,
() => ({ query: props.query, showType: props.type, results: infiniteQuery.shows.length })
props.query && props.settled && infiniteQuery.isFetched ? props.query : undefined,
() => ({ query: props.query, showType: 'all' as const, results: infiniteQuery.shows.length })
);
if (infiniteQuery.isFetched) {