@@ -21,6 +21,7 @@ import { useMemory } from '@store/useMemory'
2121import { useLayoutStore } from '@store/useLayoutStore'
2222import { useDeepStore , useStorage } from '@store/useStorage'
2323import { useGetAvailable } from '@hooks/useGetAvailable'
24+ import { getAmbiguousForms , hasAmbiguousForm } from '@utils/getAmbiguousForms'
2425import { VirtualGrid } from '@components/virtual/VirtualGrid'
2526import { TabPanel } from '@components/TabPanel'
2627import { BoolToggle } from '@components/inputs/BoolToggle'
@@ -81,53 +82,66 @@ function SelectorList({
8182 const search = useStorage ( ( s ) => s . searches [ searchKey ] || '' )
8283 const disableGutters = ! [ 'pokemon' , 'tappables' ] . includes ( category )
8384
84- const translated = React . useMemo (
85- ( ) =>
86- ( onlyShowAvailable ? available : Object . keys ( allFilters ) )
87- . filter ( ( key ) => {
88- if ( key === 'global' ) return false
89- switch ( subCategory ) {
90- case 'raids' :
91- return key . startsWith ( 'e' )
92- case 'lures' :
93- return key . startsWith ( 'l' )
94- case 'invasions' :
95- return key . startsWith ( 'i' )
96- case 'quests' :
97- return (
98- key . startsWith ( 'q' ) ||
99- key . startsWith ( 'm' ) ||
100- key . startsWith ( 'x' ) ||
101- key . startsWith ( 'c' ) ||
102- key . startsWith ( 'd' ) ||
103- key . startsWith ( 'p' ) ||
104- key . startsWith ( 'u' )
105- )
106- case 'showcase' :
107- return (
108- key . startsWith ( 'f' ) ||
109- key . startsWith ( 'h' ) ||
110- key . startsWith ( 'y' ) ||
111- key . startsWith ( 'b' )
112- )
113- case 'rocketPokemon' :
114- return key . startsWith ( 'a' )
115- case 'pokemon' :
116- return Number . isInteger ( Number ( key . charAt ( 0 ) ) )
85+ const { translated, ambiguousForms } = React . useMemo ( ( ) => {
86+ const ids = (
87+ onlyShowAvailable ? available : Object . keys ( allFilters )
88+ ) . filter ( ( key ) => {
89+ if ( key === 'global' ) return false
90+ switch ( subCategory ) {
91+ case 'raids' :
92+ return key . startsWith ( 'e' )
93+ case 'lures' :
94+ return key . startsWith ( 'l' )
95+ case 'invasions' :
96+ return key . startsWith ( 'i' )
97+ case 'quests' :
98+ return (
99+ key . startsWith ( 'q' ) ||
100+ key . startsWith ( 'm' ) ||
101+ key . startsWith ( 'x' ) ||
102+ key . startsWith ( 'c' ) ||
103+ key . startsWith ( 'd' ) ||
104+ key . startsWith ( 'p' ) ||
105+ key . startsWith ( 'u' )
106+ )
107+ case 'showcase' :
108+ return (
109+ key . startsWith ( 'f' ) ||
110+ key . startsWith ( 'h' ) ||
111+ key . startsWith ( 'y' ) ||
112+ key . startsWith ( 'b' )
113+ )
114+ case 'rocketPokemon' :
115+ return key . startsWith ( 'a' )
116+ case 'pokemon' :
117+ return Number . isInteger ( Number ( key . charAt ( 0 ) ) )
118+ default :
119+ switch ( category ) {
120+ case 'gyms' :
121+ return key . startsWith ( 't' )
122+ case 'tappables' :
123+ return key . startsWith ( 'q' ) && key !== 'q0'
117124 default :
118- switch ( category ) {
119- case 'gyms' :
120- return key . startsWith ( 't' )
121- case 'tappables' :
122- return key . startsWith ( 'q' ) && key !== 'q0'
123- default :
124- return Number . isInteger ( Number ( key . charAt ( 0 ) ) )
125- }
125+ return Number . isInteger ( Number ( key . charAt ( 0 ) ) )
126126 }
127- } )
128- . map ( ( id ) => ( { id, name : tId ( id ) . toLowerCase ( ) } ) ) ,
129- [ onlyShowAvailable ? available : allFilters , tId , category , subCategory ] ,
130- )
127+ }
128+ } )
129+ // two identical looking entries (e.g. Litleo Unset + Normal) must show
130+ // their form to be told apart, but only for as long as both are around
131+ const ambiguous = getAmbiguousForms ( ids )
132+ return {
133+ ambiguousForms : ambiguous ,
134+ translated : ids . map ( ( id ) => ( {
135+ id,
136+ name : tId ( id , {
137+ quest : subCategory === 'pokemon' ,
138+ omitFormSuffix : true ,
139+ showDefaultForms :
140+ subCategory === 'rocketPokemon' || hasAmbiguousForm ( ambiguous , id ) ,
141+ } ) . toLowerCase ( ) ,
142+ } ) ) ,
143+ }
144+ } , [ onlyShowAvailable ? available : allFilters , tId , category , subCategory ] )
131145
132146 const items = React . useMemo ( ( ) => {
133147 const lowerCase = search . toLowerCase ( )
@@ -249,7 +263,13 @@ function SelectorList({
249263 restoreStateFrom = { restoreStateFrom }
250264 stateChanged = { handleStateChanged }
251265 >
252- { ( _ , key ) => < StandardItem id = { key } category = { category } /> }
266+ { ( _ , key ) => (
267+ < StandardItem
268+ id = { key }
269+ category = { category }
270+ ambiguousForms = { ambiguousForms }
271+ />
272+ ) }
253273 </ VirtualGrid >
254274 </ Box >
255275 </ List >
0 commit comments