fix(games): update search to handle roman numerals first, skip memoize on searchTerm

This commit is contained in:
en 2025-02-03 20:14:55 +01:00
parent 93a7419006
commit 1623f80e88
2 changed files with 4 additions and 2 deletions

View File

@ -37,6 +37,7 @@ import {
extractModData,
isModDataComplete,
memoizedNormalizeSearchString,
normalizeSearchString,
scrollIntoView
} from 'utils'
import { useCuratedSet } from 'hooks/useCuratedSet'
@ -503,7 +504,7 @@ const GamesResult = ({ searchTerm }: GamesResultProps) => {
const filteredGames = useMemo(() => {
if (searchTerm === '') return []
const normalizedSearchTerm = memoizedNormalizeSearchString(searchTerm)
const normalizedSearchTerm = normalizeSearchString(searchTerm)
return games.filter((game) =>
memoizedNormalizeSearchString(game['Game Name']).includes(

View File

@ -239,9 +239,10 @@ const romanRegex = new RegExp(
export const normalizeSearchString = (str: string): string => {
str = str.toLowerCase()
str = str.replace(romanRegex, (match) => ROMAN_TO_ARABIC_MAP[match])
str = removeAccents(str)
str = removeSpecialCharacters(str)
return str.replace(romanRegex, (match) => ROMAN_TO_ARABIC_MAP[match])
return str
}
// Memoization function to cache normalized results