Fix location error appears too soon, fix logout triggers "status changed" message

master
Skylar Ittner 8 years ago
parent 382cf53cb2
commit 1b49996a64

@ -21,7 +21,6 @@
*/ */
var authOpInProgress = false; var authOpInProgress = false;
var logoutInProgress = false;
function askLogout() { function askLogout() {
navigator.notification.confirm( navigator.notification.confirm(
@ -37,21 +36,17 @@ function askLogout() {
} }
function logout() { function logout() {
logoutInProgress = true;
$.getJSON(mkApiUrl('deletesession'), {}, function (data) { $.getJSON(mkApiUrl('deletesession'), {}, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
localStorage.setItem("username", ''); localStorage.setItem("username", '');
localStorage.setItem("password", ''); localStorage.setItem("password", '');
username = null; username = null;
password = null; password = null;
openscreen('login'); document.location.href = "index.html";
logoutInProgress = false;
} else { } 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'); 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 () { }).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'); 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');
}); });
} }

@ -209,13 +209,18 @@ function pingServer() {
} }
var errorMsgShown = false; var errorMsgShown = false;
var fifteen_seconds = false;
function onError(error) { function onError(error) {
if (!errorMsgShown) { if (!errorMsgShown) {
var msg = error.message; 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"; 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; errorMsgShown = true;
} }
} }
@ -236,6 +241,9 @@ navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 1500
setInterval(function () { setInterval(function () {
navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 1000, enableHighAccuracy: true}); navigator.geolocation.getCurrentPosition(updatePosition, onError, {timeout: 1000, enableHighAccuracy: true});
}, 1000); }, 1000);
setTimeout(function () {
fifteen_seconds = true;
}, 15 * 1000);
// Update places // Update places
setInterval(function () { setInterval(function () {
loadPlaces(latitude, longitude); loadPlaces(latitude, longitude);