Skip to content

Commit

Permalink
Merge pull request #1017 from Mygod/displayless-questmon
Browse files Browse the repository at this point in the history
fix: do not set unset form on quest pokemon without display
  • Loading branch information
TurtIeSocks authored Nov 16, 2024
2 parents d11cb12 + 7356529 commit 9ed3aca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
1 change: 1 addition & 0 deletions server/src/filters/builder/pokemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function buildPokemon(defaults, base, custom) {
])

Object.entries(state.event.masterfile.pokemon).forEach(([id, pkmn]) => {
pokemon.quests[`${id}`] = new BaseFilter(defaults.pokestops.pokemon)
Object.keys(pkmn.forms).forEach((form) => {
pokemon.full[`${id}-${form}`] = base
pokemon.raids[`${id}-${form}`] = new BaseFilter(defaults.gyms.pokemon)
Expand Down
11 changes: 8 additions & 3 deletions server/src/models/Pokestop.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,11 @@ class Pokestop extends Model {
fields.push('candy_pokemon_id', 'candy_amount')
break
case 7:
quest.quest_form_id = quest.quest_form_id ?? 0
newQuest.key = `${quest.quest_pokemon_id}-${quest.quest_form_id}`
newQuest.key =
quest.quest_form_id === undefined ||
quest.quest_form_id === null
? `${quest.quest_pokemon_id}`
: `${quest.quest_pokemon_id}-${quest.quest_form_id}`
fields.push(
'quest_pokemon_id',
'quest_form_id',
Expand Down Expand Up @@ -1545,7 +1548,9 @@ class Pokestop extends Model {
default:
rewards.forEach((reward) =>
process(
`${reward.quest_pokemon_id}-${reward.form ?? 0}`,
reward.form === undefined || reward.form === null
? `${reward.quest_pokemon_id}`
: `${reward.quest_pokemon_id}-${reward.form}`,
reward.quest_title,
reward.quest_target,
),
Expand Down
15 changes: 4 additions & 11 deletions src/hooks/useTranslateById.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable no-fallthrough */
// @ts-check
import { useEffect, useMemo, useRef } from 'react'
import { useMemo } from 'react'
import { useTranslation } from 'react-i18next'

/**
Expand All @@ -14,11 +14,6 @@ import { useTranslation } from 'react-i18next'
*/
export function useTranslateById(options = {}) {
const i18n = useTranslation()
const formsToIgnore = useRef(new Set([i18n.t('form_0'), i18n.t('form_45')]))

useEffect(() => {
formsToIgnore.current = new Set([i18n.t('form_0'), i18n.t('form_45')])
}, [i18n.i18n.language])

return useMemo(
() => ({
Expand Down Expand Up @@ -114,11 +109,9 @@ export function useTranslateById(options = {}) {
// pokemon
const [pokemon, form] = id.split('-', 2)
const pokemonName = i18n.t(`poke_${pokemon}`)
const possibleForm = i18n.t(`form_${form}`)
const formName = formsToIgnore.current.has(possibleForm)
? ''
: `${newLine ? '\n' : ' '}(${possibleForm})`
return `${pokemonName}${formName}`
return form === undefined
? pokemonName
: `${pokemonName}${newLine ? '\n' : ' '}(${i18n.t(`form_${form}`)})`
}
}
},
Expand Down

0 comments on commit 9ed3aca

Please sign in to comment.