Add soft-reload after changing settings
This commit is contained in:
@@ -31,7 +31,7 @@ Pebble.addEventListener("appmessage", function (dict) {
|
||||
|
||||
function callAPI(fullURL, apiKey, isJellyfin, trackedUser, sleepTimestamp) {
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
||||
|
||||
let didReportError = false;
|
||||
function reportApiError(message) {
|
||||
if (didReportError) {
|
||||
@@ -51,17 +51,22 @@ function callAPI(fullURL, apiKey, isJellyfin, trackedUser, sleepTimestamp) {
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
if (xhr.readyState === 4) {
|
||||
if (xhr.status === 0) {
|
||||
reportApiError("API UNREACHABLE");
|
||||
return;
|
||||
}
|
||||
if (xhr.status < 200 || xhr.status >= 300) {
|
||||
if (xhr.status == 401) {
|
||||
switch (xhr.status) {
|
||||
case 200:
|
||||
break;
|
||||
case 0:
|
||||
reportApiError("API UNREACHABLE");
|
||||
return;
|
||||
case 401:
|
||||
case 403:
|
||||
reportApiError("API ERROR: " + xhr.status + " (CHECK API KEY)");
|
||||
} else {
|
||||
return;
|
||||
case 404:
|
||||
case 405:
|
||||
reportApiError("API ERROR: " + xhr.status + " (INVALID ENDPOINT?)");
|
||||
return;
|
||||
default:
|
||||
reportApiError("API ERROR: " + xhr.status);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (!xhr.responseText) {
|
||||
reportApiError("API EMPTY RESPONSE");
|
||||
@@ -111,9 +116,8 @@ function callAPI(fullURL, apiKey, isJellyfin, trackedUser, sleepTimestamp) {
|
||||
});
|
||||
}
|
||||
if (lastWatched != "") {
|
||||
//console.log("Last watched: " + lastWatched);
|
||||
Pebble.sendAppMessage({ PKJS_LAST_WATCHED: lastWatched });
|
||||
} else {
|
||||
} else {
|
||||
Pebble.sendAppMessage({ PKJS_LAST_WATCHED: "NO WATCH HISTORY FOUND FOR USER " + trackedUser });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user