Update explore context with current location on permission being granted (#1831)

This commit is contained in:
Johannes Klein
2024-07-19 12:21:03 +02:00
committed by GitHub
parent 00678d169f
commit 2a2983caed

View File

@@ -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" ) } )}
</>
);
};