Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Oct 15, 2024
1 parent 17c18b5 commit 3b068ed
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/366x366/app/connectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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+`;
Expand Down
7 changes: 3 additions & 4 deletions src/366x366/app/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
16 changes: 8 additions & 8 deletions src/366x366/companion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 7 additions & 9 deletions src/366x366/shared/msgq.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -251,7 +250,7 @@ function delayedProcess(delay) {
let msToEnd = delayedProcessCallAt - new Date().getTime();

if (msToEnd > delay) {
setNewTime = true;
setNewTime = true;
}
}

Expand Down Expand Up @@ -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}`);
Expand Down Expand Up @@ -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}`);
});
}
Expand Down

0 comments on commit 3b068ed

Please sign in to comment.