Fix bugs when adding activity

This commit is contained in:
John Lyon-Smith
2018-04-27 18:10:39 -07:00
parent 93f3d462b2
commit 53a4df55a2
8 changed files with 138 additions and 79 deletions

View File

@@ -66,11 +66,8 @@ export class Home extends React.Component {
results[PermissionsAndroid.PERMISSIONS.ACCESS_FINE_LOCATION] ===
PermissionsAndroid.RESULTS.GRANTED
) {
this.watchId = navigator.geolocation.watchPosition(
this.handlePositionChange,
null,
{ distanceFilter: 10 }
)
this.setState({ haveLocationPermission: true })
navigator.geolocation.getCurrentPosition(this.handlePositionChange)
}
if (
@@ -250,9 +247,18 @@ export class Home extends React.Component {
positionInfo,
messageModal,
haveCameraPermission,
haveLocationPermission,
workItemDistance,
} = this.state
if (!this.watchId && haveLocationPermission) {
this.watchId = navigator.geolocation.watchPosition(
this.handlePositionChange,
null,
{ distanceFilter: 10 }
)
}
return (
<View
style={{
@@ -268,7 +274,9 @@ export class Home extends React.Component {
!(
positionInfo &&
positionInfo.coords.accuracy <= config.minGPSAccuracy
) || !haveCameraPermission
) ||
!haveCameraPermission ||
!haveLocationPermission
}
/>
<MapView