Fix location error appears too soon, fix logout triggers "status changed" message
This commit is contained in:
parent
382cf53cb2
commit
1b49996a64
@ -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');
|
||||
});
|
||||
}
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user