From 1b49996a64e1cb6cc1ee362250b7ca1e14652f6d Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Wed, 30 Nov 2016 15:44:56 -0700 Subject: [PATCH] Fix location error appears too soon, fix logout triggers "status changed" message --- www/js/auth.js | 7 +------ www/js/location.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/www/js/auth.js b/www/js/auth.js index 74be051..b5d7ea6 100644 --- a/www/js/auth.js +++ b/www/js/auth.js @@ -21,7 +21,6 @@ */ var authOpInProgress = false; -var logoutInProgress = false; function askLogout() { navigator.notification.confirm( @@ -37,21 +36,17 @@ function askLogout() { } function logout() { - logoutInProgress = true; $.getJSON(mkApiUrl('deletesession'), {}, function (data) { if (data.status === 'OK') { localStorage.setItem("username", ''); localStorage.setItem("password", ''); username = null; password = null; - openscreen('login'); - logoutInProgress = false; + document.location.href = "index.html"; } else { - logoutInProgress = false; navigator.notification.alert("Server did not properly acknowledge logout. You might have problems for the next few hours if you switch accounts.", null, "Error", 'Dismiss'); } }).fail(function () { - logoutInProgress = false; navigator.notification.alert("Cannot connect to server. Check your Internet connection and try again. If that fails, clear the app data or reinstall TerranQuest.", null, "Error", 'Dismiss'); }); } diff --git a/www/js/location.js b/www/js/location.js index fc83d4c..b003cec 100644 --- a/www/js/location.js +++ b/www/js/location.js @@ -209,13 +209,18 @@ function pingServer() { } var errorMsgShown = false; +var fifteen_seconds = false; function onError(error) { if (!errorMsgShown) { var msg = error.message; - if (msg.toLowerCase().includes("timeout")) { + if (msg.toLowerCase().includes("timeout") && fifteen_seconds == false) { + return; + } else if (msg.toLowerCase().includes("timeout")) { msg = "no lock within 15 seconds"; + $('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky (" + msg + ")."); + } else { + $('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky (" + msg + ")."); } - $('#loading-error').text("Check your device's network and location settings, and ensure a clear view of the sky (" + msg + ")."); errorMsgShown = true; } } @@ -236,6 +241,9 @@ navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 1500 setInterval(function () { navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 1000, enableHighAccuracy: true}); }, 1000); +setTimeout(function () { + fifteen_seconds = true; +}, 15 * 1000); // Update places setInterval(function () { loadPlaces(latitude, longitude);