Fixed: Improve filtering performance in Select Movie Modal

pull/10205/head
Bogdan 4 months ago committed by GitHub
parent 6ed3045433
commit 270df9d1dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -162,16 +162,21 @@ function SelectMovieModalContent(props: SelectMovieModalContentProps) {
[allMovies, onMovieSelect]
);
const items = useMemo(() => {
const sorted = [...allMovies].sort(sortByProp('sortTitle'));
const sortedMovies = useMemo(
() => [...allMovies].sort(sortByProp('sortTitle')),
[allMovies]
);
return sorted.filter(
const items = useMemo(
() =>
sortedMovies.filter(
(item) =>
item.title.toLowerCase().includes(filter.toLowerCase()) ||
item.tmdbId.toString().includes(filter) ||
item.imdbId?.includes(filter)
),
[sortedMovies, filter]
);
}, [allMovies, filter]);
return (
<ModalContent onModalClose={onModalClose}>

Loading…
Cancel
Save