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] [allMovies, onMovieSelect]
); );
const items = useMemo(() => { const sortedMovies = useMemo(
const sorted = [...allMovies].sort(sortByProp('sortTitle')); () => [...allMovies].sort(sortByProp('sortTitle')),
[allMovies]
return sorted.filter( );
(item) =>
item.title.toLowerCase().includes(filter.toLowerCase()) || const items = useMemo(
item.tmdbId.toString().includes(filter) || () =>
item.imdbId?.includes(filter) sortedMovies.filter(
); (item) =>
}, [allMovies, filter]); item.title.toLowerCase().includes(filter.toLowerCase()) ||
item.tmdbId.toString().includes(filter) ||
item.imdbId?.includes(filter)
),
[sortedMovies, filter]
);
return ( return (
<ModalContent onModalClose={onModalClose}> <ModalContent onModalClose={onModalClose}>

Loading…
Cancel
Save