fix(games): update search to handle roman numerals first, skip memoize on searchTerm
This commit is contained in:
parent
93a7419006
commit
1623f80e88
@ -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(
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user