Skip to content

Commit

Permalink
Reformat documents
Browse files Browse the repository at this point in the history
  • Loading branch information
BlythMeister committed Sep 11, 2024
1 parent b3cfecc commit 7ebe461
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 177 deletions.
9 changes: 4 additions & 5 deletions src/366x366/app/connectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,12 @@ export function drawState() {
} else {
lastMsgReceivedEl.text = `>> ${receivedAgeDisplay.toFixed(1)}`;
}

queueSizeEl.text = `A:${msgq.getQueueSize()} / C:${msgq.getOtherQueueSize()}`;
if(msgq.getIsWaitingForResponse())
{
queueSizeEl.text += " / W"
if (msgq.getIsWaitingForResponse()) {
queueSizeEl.text += " / W";
}

if (lastReceivedAge >= 900000) {
disconnected = true;
phoneIconEl.style.fill = disconnectedColour;
Expand Down
4 changes: 2 additions & 2 deletions src/366x366/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ if (settings.hasSettings()) {
startingEl.style.display = "none";
} else {
setTimeout(() => {
if(startingEl.style.display == "inline") {
if (startingEl.style.display == "inline") {
startingEl.style.display = "none";
console.log(`Hiding loading spinner after 120 seconds if still shown`);
}
}
}, 120000);
}

Expand Down
17 changes: 8 additions & 9 deletions src/366x366/app/weather.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function forceFetchWeather() {
}

export function fetchWeather() {
if(startingEl.style.display == "inline" || weatherPosition == "NONE") {
if (startingEl.style.display == "inline" || weatherPosition == "NONE") {
// Don't try and get weather when starting or hidden
return;
}
Expand All @@ -117,30 +117,29 @@ export function fetchWeather() {
currentWeatherData.location = "Expired";
DrawWeather();
}

if (lastRequestAge >= 300000 || (currentWeatherData == null && lastRequestAge >= 60000)) {

if (lastRequestAge >= 300000 || (currentWeatherData == null && lastRequestAge >= 60000)) {
weatherLastRequest = Date.now();

if (currentWeatherData == null || currentWeatherData.condition === -1 || currentWeatherAge >= weatherInterval) {
try {
let sendUnit = temperatureUnit;
if (sendUnit == "auto") {
sendUnit = units.temperature ? units.temperature.charAt(0).toUpperCase() : "C";
}
}
msgq.send("weather", { unit: sendUnit }, 60000, false);
} catch (e) {
console.error(e);
}
}
}
}
}

export function processWeatherData(data) {
var currentDate = Date.now();
if (currentWeatherData != null && data != null && currentWeatherData.condition >= 0 && data.condition === -1) {
var currentWeatherAge = weatherLastUpdate == null ? 99999999 : currentDate - weatherLastUpdate;
if(currentWeatherAge < weatherInterval * 2) {
if (currentWeatherAge < weatherInterval * 2) {
return;
}
}
Expand All @@ -157,13 +156,13 @@ export function DrawWeather() {
} else if (currentWeatherData.condition === -1) {
weatherCountEl.text = "----";
weatherIconEl.href = "weather_36px.png";
if(currentWeatherData.location == "Weather Service is unavailable"){
if (currentWeatherData.location == "Weather Service is unavailable") {
weatherLocationTextEl.text = "Unavailable";
} else {
weatherLocationTextEl.text = currentWeatherData.location;
}
}
} else {
if(currentWeatherData.condition >= 1 && currentWeatherData.condition <= 44) {
if (currentWeatherData.condition >= 1 && currentWeatherData.condition <= 44) {
weatherIconEl.href = weatherConditions[currentWeatherData.condition];
} else {
weatherIconEl.href = "weather_36px.png";
Expand Down
15 changes: 7 additions & 8 deletions src/366x366/companion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ settingsStorage.addEventListener("change", (evt) => {
function sendSettingsWithDefaults() {
var currentDate = Date.now();
var lastSendAllSettingsAge = lastSendAllSettings == null ? 99999999 : currentDate - lastSendAllSettings;
if(lastSendAllSettingsAge <= 60000)
{
if (lastSendAllSettingsAge <= 60000) {
return;
}
lastSendAllSettings = currentDate;
Expand Down Expand Up @@ -141,7 +140,7 @@ function sendSettingValue(key, val, updatedValue) {
}
}

function sendWeather(unit, retry=false) {
function sendWeather(unit, retry = false) {
let unitKey = "celsius";
if (unit == "F") {
unitKey = "fahrenheit";
Expand All @@ -166,10 +165,10 @@ function sendWeather(unit, retry=false) {
location: location.name,
};
//console.log(`Weather:${JSON.stringify(sendData)}`);
msgq.send("weather", sendData, 60000, false);
msgq.send("weather", sendData, 60000, false);
})
.catch((ex) => {
if(!retry) {
if (!retry) {
console.log(`Retry weather...`);
sendWeather(unit, true);
} else {
Expand All @@ -178,13 +177,13 @@ function sendWeather(unit, retry=false) {
temperature: -999,
unit: unitKey,
condition: -1,
location: ex.message
location: ex.message,
};
msgq.send("weather", sendData, 60000, false);
}
});
} catch (ex) {
if(!retry) {
if (!retry) {
console.log(`Retry weather...`);
sendWeather(unit, true);
} else {
Expand All @@ -193,7 +192,7 @@ function sendWeather(unit, retry=false) {
temperature: -999,
unit: unitKey,
condition: -1,
location: ex.message
location: ex.message,
};
msgq.send("weather", sendData, 60000, false);
}
Expand Down
Loading

0 comments on commit 7ebe461

Please sign in to comment.