Skip to content

Commit 5e57d50

Browse files
committed
feat: display amount in quest tooltip
1 parent c6f9312 commit 5e57d50

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

src/features/pokestop/PokestopPopup.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,38 @@ const RewardInfo = ({ with_ar, ...quest }) => {
541541
const { src, amount, tt } = getRewardInfo(quest)
542542
const questMessage = useMemory((s) => s.config.misc.questMessage)
543543

544+
const labelKeys = Array.isArray(tt) ? tt.filter(Boolean) : tt ? [tt] : []
545+
const translatedLabel = labelKeys.length
546+
? labelKeys.map((key) => t(key)).join(' ')
547+
: ''
548+
const fallbackLabel = labelKeys.join(' ') || 'quest reward'
549+
const altLabel = (translatedLabel || fallbackLabel).trim()
550+
551+
const overrideAmount = Number(
552+
{
553+
1: quest.xp_amount,
554+
2: quest.item_amount,
555+
3: quest.stardust_amount,
556+
4: quest.candy_amount,
557+
9: quest.xl_candy_amount,
558+
12: quest.mega_amount,
559+
}[quest.quest_reward_type] ?? 0,
560+
)
561+
const altAmount =
562+
typeof amount === 'number' && amount > 0
563+
? amount
564+
: Number.isFinite(overrideAmount) && overrideAmount > 0
565+
? overrideAmount
566+
: 0
567+
const altText = altAmount > 0 ? `${altLabel} x${altAmount}` : altLabel
568+
544569
return (
545570
<Grid xs={3} style={{ textAlign: 'center', position: 'relative' }}>
546-
<NameTT title={tt}>
571+
<NameTT title={altText}>
547572
<img
548573
src={src}
549574
style={{ maxWidth: 35, maxHeight: 35 }}
550-
alt={typeof tt === 'string' ? tt : tt.join(' ')}
575+
alt={altText}
551576
onError={(e) => {
552577
// @ts-ignore
553578
e.target.onerror = null

0 commit comments

Comments
 (0)