Skip to content

Commit 0f157ed

Browse files
committed
fix: remove extra Forms
1 parent b2ea525 commit 0f157ed

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

src/components/filters/Advanced.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,9 @@ export function AdvancedFilter() {
126126
category === 'pokemon' || (!id.startsWith('l') && !id.startsWith('i'))
127127
? t('advanced')
128128
: t('set_size')
129-
} - ${tId(id)}`}
129+
} - ${tId(id, {
130+
omitFormSuffix: true,
131+
})}`}
130132
action={() => toggleClose(false)}
131133
/>
132134
<DialogContent sx={{ mt: 3 }}>

src/components/virtual/SelectorItem.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export function SelectorItem({
4848
alt: true,
4949
newLine: true,
5050
quest: category === 'pokestops',
51+
omitFormSuffix: true,
5152
})
5253
const title = t(id)
5354
const url = useMemory((s) => s.Icons.getIconById(id))

src/features/drawer/components/SelectorList.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ function SelectorList({ category, subCategory, label, height = 400 }) {
4545
subCategory ? capitalize(subCategory) : ''
4646
}QuickSelect`
4747
const { available } = useGetAvailable(category)
48-
const { t: tId } = useTranslateById({ quest: subCategory === 'pokemon' })
48+
const { t: tId } = useTranslateById({
49+
quest: subCategory === 'pokemon',
50+
omitFormSuffix: true,
51+
})
4952
const { t } = useTranslation()
5053
const allFilters = useMemory((s) => s.filters[category]?.filter)
5154

src/hooks/useTranslateById.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
55
import { getFormDisplay } from '@utils/getFormDisplay'
66

77
/**
8-
* @typedef {{ plural?: boolean, amount?: boolean, alt?: boolean, newLine?: boolean, quest?: boolean }} CustomTOptions
8+
* @typedef {{ plural?: boolean, amount?: boolean, alt?: boolean, newLine?: boolean, quest?: boolean, omitFormSuffix?: boolean }} CustomTOptions
99
* @typedef {(id: string, options?: CustomTOptions) => string} CustomT
1010
*/
1111

@@ -19,7 +19,10 @@ export function useTranslateById(options = {}) {
1919
return useMemo(
2020
() => ({
2121
language: i18n.i18n.language,
22-
t: (id, { plural, amount, alt, newLine, quest } = options) => {
22+
t: (
23+
id,
24+
{ plural, amount, alt, newLine, quest, omitFormSuffix } = options,
25+
) => {
2326
if (typeof id !== 'string') {
2427
return ''
2528
}
@@ -116,6 +119,7 @@ export function useTranslateById(options = {}) {
116119
? ''
117120
: getFormDisplay(pokemon, form, undefined, {
118121
showDefaultForms: quest,
122+
appendFormSuffix: !omitFormSuffix,
119123
})
120124
return formLabel
121125
? `${pokemonName}${newLine ? '\n' : ' '}(${formLabel})`
@@ -124,6 +128,13 @@ export function useTranslateById(options = {}) {
124128
}
125129
},
126130
}),
127-
[i18n, options.alt, options.amount, options.plural, options.newLine],
131+
[
132+
i18n,
133+
options.alt,
134+
options.amount,
135+
options.plural,
136+
options.newLine,
137+
options.omitFormSuffix,
138+
],
128139
)
129140
}

src/utils/getFormDisplay.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const ALWAYS_SHOW_FORM_POKEMON = new Set([51]) // Dugtrio (51) needs form labels
1010
* @param {number | string | null | undefined} pokemonId
1111
* @param {number | string | null | undefined} form
1212
* @param {number | string | null | undefined} costume
13-
* @param {{ showDefaultForms?: boolean }} [options]
13+
* @param {{ showDefaultForms?: boolean, appendFormSuffix?: boolean }} [options]
1414
* @returns {string}
1515
*/
1616
export function getFormDisplay(pokemonId, form, costume, options = {}) {
@@ -34,7 +34,7 @@ export function getFormDisplay(pokemonId, form, costume, options = {}) {
3434
return `${translate('form')} ${form}`
3535
}
3636

37-
const { showDefaultForms = false } = options
37+
const { showDefaultForms = false, appendFormSuffix = true } = options
3838
if (!showDefaultForms) {
3939
const normalizedPokemonId =
4040
typeof pokemonId === 'number'
@@ -52,6 +52,8 @@ export function getFormDisplay(pokemonId, form, costume, options = {}) {
5252
return ''
5353
}
5454

55+
if (!appendFormSuffix) return formName
56+
5557
const suffix = ` ${translate('form')}`
5658
return formName.endsWith(suffix) ? formName : `${formName}${suffix}`
5759
}

0 commit comments

Comments
 (0)