Some caching fixes

This commit is contained in:
Martin Donnelly 2018-10-18 21:41:42 +01:00
parent ff35edec7a
commit ff038a70c4
2 changed files with 12 additions and 4 deletions

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const CACHE_VERSION = { 'version': '0.0.891' };
const CACHE_VERSION = { 'version': '0.0.892' };
const PRECACHE = `jubileeData-${CACHE_VERSION.version}`;
const RUNTIME = 'runtime';

View File

@ -57,9 +57,9 @@ const LocationModel = Backbone.Model.extend({
if (now.getTime() - this.throttler > 30000) {
this.processPosition(location);
this.throttler = now.getTime() + 1000;
} else {
console.log('Throttling location update...');
}
else
console.log('Throttling location update...');
// this.set('location', location);
}.bind(this));
@ -98,6 +98,14 @@ const LocationModel = Backbone.Model.extend({
// rawburn house 51.490002, -0.140245
// thomas more 51.5084707,-0.068798
const distanceFromLast = distance(current.latitude, current.longitude, latitude, longitude);
if (distanceFromLast < 0.001) {
console.log('Insignificant distance, bail');
return;
}
const geocoder = NodeGeocoder(options);
// 55.872407, -3.549003
const homeDistance = distance(myCoords.home.lat, myCoords.home.long, latitude, longitude);
@ -141,7 +149,7 @@ const LocationModel = Backbone.Model.extend({
else {
newLocation.city = current.city;
const currentTime = new Date().getTime();
const distanceFromLast = distance(current.latitude, current.longitude, latitude, longitude);
const lastGeocode = this.get('lastGeocode');
const distanceFromLastGeocode = distance(lastGeocode.lat, lastGeocode.lng, latitude, longitude);