mirror of
https://github.com/inaturalist/iNaturalistReactNative.git
synced 2026-05-07 23:26:56 -04:00
Update explore context with current location on permission being granted (#1831)
This commit is contained in:
@@ -32,18 +32,26 @@ const RootExploreContainerWithContext = ( ): Node => {
|
||||
} = useLocationPermission( );
|
||||
|
||||
const {
|
||||
state, dispatch, makeSnapshot
|
||||
state, dispatch, makeSnapshot, defaultExploreLocation
|
||||
} = useExplore( );
|
||||
|
||||
const [showFiltersModal, setShowFiltersModal] = useState( false );
|
||||
|
||||
const updateLocation = ( place: Object ) => {
|
||||
const updateLocation = async ( place: Object ) => {
|
||||
if ( place === "worldwide" ) {
|
||||
dispatch( { type: EXPLORE_ACTION.SET_PLACE_MODE_WORLDWIDE } );
|
||||
dispatch( {
|
||||
type: EXPLORE_ACTION.SET_PLACE,
|
||||
placeId: null
|
||||
} );
|
||||
} else if ( place === "nearby" ) {
|
||||
const exploreLocation = await defaultExploreLocation( );
|
||||
// exploreLocation has a placeMode already
|
||||
// dispatch( { type: EXPLORE_ACTION.SET_PLACE_MODE_NEARBY } );
|
||||
dispatch( {
|
||||
type: EXPLORE_ACTION.SET_EXPLORE_LOCATION,
|
||||
exploreLocation
|
||||
} );
|
||||
} else {
|
||||
navigation.setParams( { place } );
|
||||
dispatch( { type: EXPLORE_ACTION.SET_PLACE_MODE_PLACE } );
|
||||
@@ -129,7 +137,7 @@ const RootExploreContainerWithContext = ( ): Node => {
|
||||
hasLocationPermissions={hasLocationPermissions}
|
||||
requestLocationPermissions={requestLocationPermissions}
|
||||
/>
|
||||
{renderPermissionsGate( )}
|
||||
{renderPermissionsGate( { onPermissionGranted: () => updateLocation( "nearby" ) } )}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user