From 270df9d1dd7419cba9be42b5c1b4c2e7f729ac6a Mon Sep 17 00:00:00 2001 From: Bogdan Date: Thu, 25 Jul 2024 07:23:32 +0300 Subject: [PATCH] Fixed: Improve filtering performance in Select Movie Modal --- .../Movie/SelectMovieModalContent.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/frontend/src/InteractiveImport/Movie/SelectMovieModalContent.tsx b/frontend/src/InteractiveImport/Movie/SelectMovieModalContent.tsx index 7a00c7cf0..cca8982f5 100644 --- a/frontend/src/InteractiveImport/Movie/SelectMovieModalContent.tsx +++ b/frontend/src/InteractiveImport/Movie/SelectMovieModalContent.tsx @@ -162,16 +162,21 @@ function SelectMovieModalContent(props: SelectMovieModalContentProps) { [allMovies, onMovieSelect] ); - const items = useMemo(() => { - const sorted = [...allMovies].sort(sortByProp('sortTitle')); - - return sorted.filter( - (item) => - item.title.toLowerCase().includes(filter.toLowerCase()) || - item.tmdbId.toString().includes(filter) || - item.imdbId?.includes(filter) - ); - }, [allMovies, filter]); + const sortedMovies = useMemo( + () => [...allMovies].sort(sortByProp('sortTitle')), + [allMovies] + ); + + const items = useMemo( + () => + sortedMovies.filter( + (item) => + item.title.toLowerCase().includes(filter.toLowerCase()) || + item.tmdbId.toString().includes(filter) || + item.imdbId?.includes(filter) + ), + [sortedMovies, filter] + ); return (