From 88f6f54aabe3343499c2b97d4b68161005865f63 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sun, 5 May 2019 20:44:14 -0600 Subject: [PATCH] Make geolocation errors less annoying --- www/js/map.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/www/js/map.js b/www/js/map.js index a3e0ade..5709de0 100644 --- a/www/js/map.js +++ b/www/js/map.js @@ -61,7 +61,9 @@ function mapEasing(t) { return t * (2 - t); } -gotfirstfix = false; +var gotfirstfix = false; + +var geoerrorcount = 0; watchLocation(function (position) { if (gotfirstfix) { @@ -72,11 +74,17 @@ watchLocation(function (position) { gotfirstfix = true; } }, function (error) { + geoerrorcount++; + console.log("Geolocation error #" + geoerrorcount + ": ", error); + // Stop showing error toasts if they're happening a lot + if (geoerrorcount > 3) { + return; + } app.toast.show({ text: ' ' + error, position: "bottom", destroyOnClose: true, - closeTimeout: 5000 + closeTimeout: 1000 * 4 }); });