Skip to content

Commit

Permalink
Fix to replace code lost during merge Path-Check#37 (Path-Check#55)
Browse files Browse the repository at this point in the history
The LocationServices refactor merge lost the changes that happened to
adding "curation" to the point data (PR Path-Check#35).  This restores it.
  • Loading branch information
penrods authored and SamMakesThings committed Mar 22, 2020
1 parent 23e3f7d commit 16ff2f4
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions app/services/LocationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,31 @@ export default class LocationServices {
locationData = [];
}

locationData.push(location);
console.log('[GPS] Saving point:', locationData.length);
// Curate the list of points
SetStoreData('LOCATION_DATA', locationData); var nowUTC = new Date().toISOString();
var unixtimeUTC = Date.parse(nowUTC);
var unixtimeUTC_28daysAgo = unixtimeUTC - (60 * 60 * 24 * 1000 * 28);

var curated = [];
for (var i = 0; i < locationData.length; i++) {
if (locationData[i]["time"] > unixtimeUTC_28daysAgo) {
curated.push(locationData[i]);
}
}

SetStoreData('LOCATION_DATA', locationData);
// Save the location using the current lat-lon and the
// calculated UTC time (maybe a few milliseconds off from
// when the GPS data was collected, but that's unimportant
// for what we are doing.)
console.log('[GPS] Saving point:', locationData.length);
var lat_lon_time = {
"latitude": location["latitude"],
"longitude": location["longitude"],
"time": unixtimeUTC
};
curated.push(lat_lon_time);

SetStoreData('LOCATION_DATA', curated);
});

// to perform long running operation on iOS
Expand Down Expand Up @@ -100,14 +121,14 @@ export default class LocationServices {
// we need to set delay or otherwise alert may not be shown
setTimeout(() =>
Alert.alert('App requires location tracking permission', 'Would you like to open app settings?', [{
text: 'Yes',
onPress: () => BackgroundGeolocation.showAppSettings()
},
{
text: 'No',
onPress: () => console.log('No Pressed'),
style: 'cancel'
}
text: 'Yes',
onPress: () => BackgroundGeolocation.showAppSettings()
},
{
text: 'No',
onPress: () => console.log('No Pressed'),
style: 'cancel'
}
]), 1000);
}
});
Expand Down

0 comments on commit 16ff2f4

Please sign in to comment.