Skip to content

Commit a2b085d

Browse files
authored
Merge pull request #118 from 2skydev/dev
v0.0.24
2 parents c208d24 + af09c4d commit a2b085d

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/renderer/src/features/duo/DuoSynergyTable/DuoSynergyTable.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export interface DuoSynergyForm extends Omit<GetDuoSynergyListOptions, 'champion
4141

4242
export interface FilteredChampionItem {
4343
id: number
44-
enName: string
44+
normalizedName: string
4545
alias: string[]
4646
}
4747

@@ -103,17 +103,20 @@ const DuoSynergyTable = ({ className }: DuoSynergyTableProps) => {
103103
useEffect(() => {
104104
const championNameAlias = t('league.championNameAlias', { returnObjects: true })
105105

106+
const query = search.replaceAll(' ', '').toLowerCase()
107+
106108
const filteredChampions =
107-
!championNames || !search.trim().length
109+
!championNames || !query.length
108110
? []
109111
: Object.keys(championNames).reduce<FilteredChampionItem[]>((acc, id) => {
110-
const enName = championNames[id].en
112+
const { en: enName, ko: name } = championNames[id]
111113
const alias = championNameAlias[enName] ?? []
114+
const normalizedName = name.replaceAll(' ', '').toLowerCase()
112115

113-
if (includesByCho(search, enName) || alias.some(x => includesByCho(search, x))) {
116+
if (includesByCho(query, normalizedName) || alias.some(x => includesByCho(query, x))) {
114117
acc.push({
115118
id: +id,
116-
enName,
119+
normalizedName,
117120
alias,
118121
})
119122
}
@@ -122,12 +125,12 @@ const DuoSynergyTable = ({ className }: DuoSynergyTableProps) => {
122125
}, [])
123126

124127
const distanceChampionNames: string[] = correctByDistance(
125-
search,
126-
filteredChampions.map(x => x.enName),
128+
query,
129+
filteredChampions.map(x => x.normalizedName),
127130
)
128131

129132
const filteredChampionId: number | null = distanceChampionNames.length
130-
? filteredChampions.find(x => x.enName === distanceChampionNames[0])!.id
133+
? filteredChampions.find(x => x.normalizedName === distanceChampionNames[0])!.id
131134
: filteredChampions.length === 1
132135
? filteredChampions[0].id
133136
: null

0 commit comments

Comments
 (0)