Skip to content

Commit

Permalink
fix: Don't remember last location when permissions are denied
Browse files Browse the repository at this point in the history
  • Loading branch information
knipec committed Nov 11, 2024
1 parent 2373d90 commit 72ae8d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions dev-client/src/screens/BottomTabsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export const BottomTabsScreen = memo(() => {
locationManager.addListener(listener);

return () => locationManager.removeListener(listener);
} else {
dispatch(updateLocation({coords: null, accuracyM: null}));
}
}, [dispatch, locationPermissions?.granted]);

Expand Down
4 changes: 3 additions & 1 deletion dev-client/src/screens/SitesScreen/SitesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ export const SitesScreen = memo(() => {
}
}, [dispatch, currentUserID]);

const currentUserCoords = useSelector(state => state.map.userLocation.coords);
const currentUserCoords = useSelector(
state => state.map.userLocation?.coords,
);

const [finishedLoading, setFinishedLoading] = useState(false);
const [finishedInitialCameraMove, setFinishedInitialCameraMove] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const CustomUserLocation = ({
const userLocation = useSelector(state => state.map.userLocation);

const feature = useMemo(() => {
// Coords should be null when permissions are not granted
if (userLocation.coords === null) {
return null;
}
Expand Down

0 comments on commit 72ae8d2

Please sign in to comment.