Deal with initially having no work items

This commit is contained in:
John Lyon-Smith
2018-04-26 15:48:56 -07:00
parent 0a5677b59b
commit 5e5daa2e78
7 changed files with 1504 additions and 1464 deletions

View File

@@ -41,12 +41,7 @@ export class Home extends React.Component {
this.state = {
sections: [],
showWorkItems: true,
region: {
latitude: 43.653908,
longitude: -79.384293,
latitudeDelta: 0.0922,
longitudeDelta: 0.0922,
},
region: config.initialRegion,
positionInfo: null,
haveCameraPermission: false,
workItemDistance: -1,
@@ -104,10 +99,11 @@ export class Home extends React.Component {
.then((list) => {
this.setState({
sections: list.items,
region: regionContainingPoints(
list.items.map((item) => item.coordinate),
0.02
),
region:
regionContainingPoints(
list.items.map((item) => item.coordinate),
0.02
) || this.state.region,
})
})
.catch((err) => {
@@ -198,14 +194,15 @@ export class Home extends React.Component {
@autobind
handleGlassesPress() {
const { sections: workItems } = this.state
const {
latitude: latitude1,
longitude: longitude1,
} = this.state.positionInfo.coords
let closestWorkItem = null
let closestWorkItem = config.alwaysShowWorkItemInAR ? workItems[0] : null
let shortestDistance = config.minDistanceToItem
this.state.sections.forEach((workItem) => {
workItems.forEach((workItem) => {
const { latitude: latitude2, longitude: longitude2 } = workItem.coordinate
const distance =
geoDistance(latitude1, longitude1, latitude2, longitude2, "K") * 1000