@@ -65,6 +65,18 @@ export function PokestopPopup({
6565 'Pokestop' ,
6666 )
6767
68+ const getPokemonBackgroundVisuals = usePokemonBackgroundVisuals ( )
69+ const questVisuals = React . useMemo ( ( ) => {
70+ if ( ! Array . isArray ( pokestop . quests ) ) {
71+ return [ ]
72+ }
73+ return pokestop . quests . map ( ( quest ) =>
74+ quest . quest_reward_type === 7
75+ ? getPokemonBackgroundVisuals ( quest . quest_background )
76+ : undefined ,
77+ )
78+ } , [ getPokemonBackgroundVisuals , pokestop . quests ] )
79+
6880 const plainPokestop = ! hasLure && ! hasQuest && ! hasInvasion && ! hasEvent
6981
7082 return (
@@ -114,19 +126,29 @@ export function PokestopPopup({
114126 { hasQuest &&
115127 // eslint-disable-next-line no-unused-vars
116128 pokestop . quests . map ( ( { key, ...quest } , index ) => {
117- const isBackgroundReward = quest . quest_reward_type === 7
118- const previousWasBackground =
119- index > 0 &&
120- pokestop . quests [ index - 1 ] ?. quest_reward_type === 7
129+ const visuals =
130+ questVisuals [ index ] ||
131+ ( quest . quest_reward_type === 7
132+ ? getPokemonBackgroundVisuals ( quest . quest_background )
133+ : undefined )
134+ const hasBackground = Boolean ( visuals ?. hasBackground )
135+ const previousHasBackground =
136+ index > 0
137+ ? Boolean ( questVisuals [ index - 1 ] ?. hasBackground )
138+ : false
121139 const showDivider =
122- index && ! isBackgroundReward && ! previousWasBackground
140+ index && ! ( hasBackground || previousHasBackground )
123141
124142 return (
125143 < React . Fragment key = { `${ quest . with_ar } ` } >
126144 { showDivider ? (
127145 < Divider light flexItem className = "popup-divider" />
128146 ) : null }
129- < QuestRewardRow quest = { quest } />
147+ < QuestRewardRow
148+ quest = { quest }
149+ visuals = { visuals }
150+ hasBackground = { hasBackground }
151+ />
130152 </ React . Fragment >
131153 )
132154 } ) }
@@ -603,22 +625,41 @@ const RewardInfo = ({ with_ar, styles, ...quest }) => {
603625
604626/**
605627 *
606- * @param {{ quest: Omit<import('@rm/types').Quest, 'key'> } } param0
628+ * @param {{
629+ * quest: Omit<import('@rm /types').Quest, 'key'>
630+ * visuals?: ReturnType<ReturnType<typeof usePokemonBackgroundVisuals>>
631+ * hasBackground?: boolean
632+ * }} props
607633 * @returns
608634 */
609- const QuestRewardRow = ( { quest } ) => {
635+ const QuestRewardRow = ( { quest, visuals : visualsProp , hasBackground } ) => {
610636 const { quest_reward_type, quest_background, quest_shiny_probability } = quest
611637 const getPokemonBackgroundVisuals = usePokemonBackgroundVisuals ( )
612638 const visuals = React . useMemo (
613639 ( ) =>
640+ visualsProp ||
614641 getPokemonBackgroundVisuals (
615642 quest_reward_type === 7 ? quest_background : 0 ,
616643 ) ,
617- [ getPokemonBackgroundVisuals , quest_background , quest_reward_type ] ,
644+ [
645+ visualsProp ,
646+ getPokemonBackgroundVisuals ,
647+ quest_background ,
648+ quest_reward_type ,
649+ ] ,
618650 )
619- const { styles, backgroundMeta } = visuals
620- const { surface, primaryText, secondaryText } = styles
621- const applyBackground = quest_reward_type === 7
651+ const resolvedHasBackground = hasBackground ?? visuals ?. hasBackground ?? false
652+ const { styles, backgroundMeta } = visuals || { }
653+ const surface = styles ?. surface || { }
654+ const primaryText = styles ?. primaryText || { }
655+ const secondaryText = styles ?. secondaryText || { }
656+ const icon = styles ?. icon || { }
657+ const applyBackground = quest_reward_type === 7 && resolvedHasBackground
658+ const rewardStyles = applyBackground
659+ ? { primaryText, secondaryText, icon }
660+ : undefined
661+ const primaryConditionStyle = applyBackground ? primaryText : undefined
662+ const secondaryConditionStyle = applyBackground ? secondaryText : undefined
622663 const rowStyle = applyBackground
623664 ? {
624665 display : 'flex' ,
@@ -643,7 +684,7 @@ const QuestRewardRow = ({ quest }) => {
643684
644685 const rowContent = (
645686 < div style = { rowStyle } >
646- < RewardInfo { ...quest } styles = { { primaryText , secondaryText } } />
687+ < RewardInfo { ...quest } styles = { rewardStyles } />
647688 < div
648689 style = { {
649690 flex : '1 1 0' ,
@@ -655,13 +696,13 @@ const QuestRewardRow = ({ quest }) => {
655696 >
656697 < QuestConditions
657698 { ...quest }
658- primaryTextStyle = { primaryText }
659- secondaryTextStyle = { secondaryText }
699+ primaryTextStyle = { primaryConditionStyle }
700+ secondaryTextStyle = { secondaryConditionStyle }
660701 />
661702 { ! ! quest_shiny_probability && (
662703 < >
663704 < br />
664- < Typography variant = "caption" style = { secondaryText } >
705+ < Typography variant = "caption" style = { secondaryConditionStyle } >
665706 < Trans
666707 i18nKey = "shiny_probability"
667708 components = { [ readableProbability ( quest_shiny_probability ) ] }
0 commit comments