diff --git a/src/366x366/app/connectivity.js b/src/366x366/app/connectivity.js index 0113f5d..f906daa 100644 --- a/src/366x366/app/connectivity.js +++ b/src/366x366/app/connectivity.js @@ -16,12 +16,12 @@ let firstTouch = false; setInterval(function () { var lastSent = msgq.getLastSent(); var lastReceived = msgq.getLastReceived(); - + var lastSentAge = lastSent == null ? 999999 : Date.now() - lastSent; var lastReceivedAge = lastReceived == null ? 999999 : Date.now() - lastReceived; if (lastSentAge > 150000 && lastReceivedAge > 150000) { try { - msgq.send("connectivity", { }, true); + msgq.send("connectivity", {}, true); } catch (e) { //Do Nothing } @@ -72,7 +72,7 @@ export function drawState() { var lastSentAge = lastSent == null ? 99999999 : Date.now() - lastSent; var lastReceivedAge = lastReceived == null ? 99999999 : Date.now() - lastReceived; - + var sentAgeDisplay = lastSentAge / 1000 / 60; if (sentAgeDisplay >= 100) { lastMsgSentEl.text = `<< 100+`; diff --git a/src/366x366/app/weather.js b/src/366x366/app/weather.js index 68f2347..7b4124f 100644 --- a/src/366x366/app/weather.js +++ b/src/366x366/app/weather.js @@ -154,7 +154,7 @@ export function DrawWeather() { var errorCode = 0; if (currentWeatherData == null) { - location = gettext("weather-loading"); + location = gettext("weather-loading"); } else if (currentWeatherData.condition === -1 && currentWeatherData.location === "The Weather Service is unavailable") { location = gettext("weather-unavailable"); errorCode = 1; @@ -172,9 +172,8 @@ export function DrawWeather() { location = currentWeatherData.location; } - if(errorCode > 0) - { - count = `-e${errorCode}-`; + if (errorCode > 0) { + count = `-e${errorCode}-`; } weatherIconEl.href = icon; diff --git a/src/366x366/companion/index.js b/src/366x366/companion/index.js index 4373c3d..b6f1ac5 100644 --- a/src/366x366/companion/index.js +++ b/src/366x366/companion/index.js @@ -153,20 +153,20 @@ function sendAllSettings() { } function sendWeather(unit) { - let unitKey = "celsius"; + let unitKey = "celsius"; if (unit == "F") { unitKey = "fahrenheit"; } - try { + try { localStorage.setItem("lastWeatherUnit", unitKey); - + let lastWeatherJson = localStorage.getItem("lastWeather"); - if(lastWeatherJson != null) { - let lastWeather = JSON.parse(lastWeatherJson) - console.log(`lastWeather: ${lastWeatherJson}`) + if (lastWeatherJson != null) { + let lastWeather = JSON.parse(lastWeatherJson); + console.log(`lastWeather: ${lastWeatherJson}`); let lastWeatherAge = new Date() - new Date(lastWeather.date); - + if (lastWeather.condition >= 0 && lastWeather.unit == unitKey && lastWeatherAge < 600000) { console.warn(`Weather requested again within 10 minutes (${lastWeatherAge}ms), returning old weather`); msgq.send("weather", lastWeather, true); @@ -209,7 +209,7 @@ function sendWeather(unit) { location: e.message, date: new Date(), }; - localStorage.setItem("lastWeather", null);r + localStorage.setItem("lastWeather", null); msgq.send("weather", errorWeather, true); }); } catch (e) { diff --git a/src/366x366/shared/msgq.js b/src/366x366/shared/msgq.js index a4b8c35..55780bf 100644 --- a/src/366x366/shared/msgq.js +++ b/src/366x366/shared/msgq.js @@ -56,15 +56,14 @@ function CreateUUID() { //==================================================================================================== function enqueue(messageKey, message, highPriority) { - if(queueHp.length + queueLp.length >= 99) { + if (queueHp.length + queueLp.length >= 99) { throw "Queue too big"; } const uuid = CreateUUID(); const id = `${messageKey}#${uuid}`; - const data = { id: id, uuid: uuid, messageKey: messageKey, message: message - }; + const data = { id: id, uuid: uuid, messageKey: messageKey, message: message }; dequeue(null, messageKey); if (highPriority) { @@ -251,7 +250,7 @@ function delayedProcess(delay) { let msToEnd = delayedProcessCallAt - new Date().getTime(); if (msToEnd > delay) { - setNewTime = true; + setNewTime = true; } } @@ -391,10 +390,10 @@ function onMessage(event) { } try { - onMessageHandler(messageKey, message); + onMessageHandler(messageKey, message); } catch (e) { console.error(`MQ::Error handling ${id} - ${messageKey} -> ${JSON.stringify(message)}. ${e}`); - } + } } else if (type == "msgq_receipt") { if (debugSentReceive) { console.log(`MQ::Got receipt for ${id}`); @@ -519,11 +518,10 @@ const msgq = { } else { throw `Unknown event ${event}`; } - + if (!initCalled) { initCalled = true; - initFileListener(inbox.pop) - .catch((e) => { + initFileListener(inbox.pop).catch((e) => { console.error(`MSGQ::Init error. ${e}`); }); }