@@ -8,6 +8,7 @@ import { CityData, CityPicker } from "app/Scenes/City/CityPicker"
88import { cityTabs } from "app/Scenes/City/cityTabs"
99import { SelectedPin } from "app/Scenes/Map/Components/SelectedPin"
1010import { MAX_GRAPHQL_INT } from "app/Scenes/Map/MapRenderer"
11+ import { GlobalStore } from "app/store/GlobalStore"
1112import {
1213 convertCityToGeoJSON ,
1314 fairToGeoCityFairs ,
@@ -101,6 +102,28 @@ export const GlobalMap: React.FC<Props> = (props) => {
101102 const navigation = useNavigation ( )
102103
103104 useEffect ( ( ) => {
105+ const onPressCitySwitcherButton = ( ) => {
106+ if ( ! showCityPicker ) {
107+ // Show the city picker
108+ setShowCityPicker ( true )
109+ setActiveShows ( [ ] )
110+ setActivePin ( null )
111+ } else {
112+ // Hide the city picker
113+ setShowCityPicker ( false )
114+ }
115+ }
116+
117+ const onPressUserPositionButton = ( ) => {
118+ // @ts -expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
119+ const { lat, lng } = userLocation
120+ cameraRef . current ?. setCamera ( {
121+ centerCoordinate : [ lng , lat ] ,
122+ zoomLevel : DefaultZoomLevel ,
123+ animationDuration : 500 ,
124+ } )
125+ }
126+
104127 navigation . setOptions ( {
105128 headerRight : ( ) => {
106129 return (
@@ -135,7 +158,16 @@ export const GlobalMap: React.FC<Props> = (props) => {
135158 )
136159 } ,
137160 } )
138- } , [ navigation , viewer , userLocation , showCityPicker , activePin ] )
161+ } , [
162+ navigation ,
163+ viewer ,
164+ userLocation ,
165+ showCityPicker ,
166+ activePin ,
167+ hideButtons ,
168+ safeAreaInsets . top ,
169+ currentLocation ,
170+ ] )
139171
140172 useEffect ( ( ) => {
141173 updateShowIdMap ( )
@@ -342,27 +374,7 @@ export const GlobalMap: React.FC<Props> = (props) => {
342374 }
343375 }
344376
345- const onPressCitySwitcherButton = ( ) => {
346- if ( ! showCityPicker ) {
347- // Show the city picker
348- setShowCityPicker ( true )
349- setActiveShows ( [ ] )
350- setActivePin ( null )
351- } else {
352- // Hide the city picker
353- setShowCityPicker ( false )
354- }
355- }
356-
357- const onPressUserPositionButton = ( ) => {
358- // @ts -expect-error STRICTNESS_MIGRATION --- 🚨 Unsafe legacy code 🚨 Please delete this and fix any type errors if you have time 🙏
359- const { lat, lng } = userLocation
360- cameraRef . current ?. setCamera ( {
361- centerCoordinate : [ lng , lat ] ,
362- zoomLevel : DefaultZoomLevel ,
363- animationDuration : 500 ,
364- } )
365- }
377+ const { setPreviouslySelectedCitySlug } = GlobalStore . actions . userPrefs
366378
367379 const currentFeatureCollection = ( ) : FilterData => {
368380 const filterID = cityTabs [ activeIndex ] . id
@@ -483,6 +495,8 @@ export const GlobalMap: React.FC<Props> = (props) => {
483495
484496 const onSelectCity = ( newCity : CityData ) => {
485497 setShowCityPicker ( false )
498+ console . warn ( "setPreviouslySelectedCitySlug" , newCity . slug )
499+ setPreviouslySelectedCitySlug ( newCity . slug )
486500 refetch ( { citySlug : newCity . slug , maxInt : MAX_GRAPHQL_INT } )
487501 }
488502
@@ -518,7 +532,7 @@ export const GlobalMap: React.FC<Props> = (props) => {
518532 >
519533 < MapboxGL . Camera
520534 ref = { cameraRef }
521- animationMode = "flyTo "
535+ animationMode = "moveTo "
522536 zoomLevel = { DefaultZoomLevel }
523537 minZoomLevel = { MinZoomLevel }
524538 maxZoomLevel = { MaxZoomLevel }
0 commit comments