fix extended forecast preload close #189

This commit is contained in:
Matt Walsh
2026-03-16 12:31:27 -05:00
parent 77592a08a3
commit 678f04fe42
3 changed files with 18 additions and 3 deletions

View File

@@ -261,6 +261,7 @@ const parseMessage = (event) => {
if (event?.data?.type === 'current-weather-scroll') {
if (event.data?.method === 'start') start();
if (event.data?.method === 'reload') stop(true);
if (event.data?.method === 'non-display') nonDisplay();
if (event.data?.method === 'show') show();
if (event.data?.method === 'hide') hide();
}
@@ -274,6 +275,20 @@ const hide = () => {
mainScroll.style.display = 'none';
};
const nonDisplay = () => {
if (interval) {
clearInterval(interval);
interval = null;
stop();
// if greater than default update (typically long scroll) skip to the next weather screen
if (nextUpdate > DEFAULT_UPDATE) {
screenIndex = (screenIndex + 1) % (workingScreens.length);
sinceLastUpdate = 0;
nextUpdate = DEFAULT_UPDATE;
}
}
};
const screenCount = () => workingScreens.length;
const atDefault = () => defaultScreensLoaded;

View File

@@ -138,15 +138,14 @@ const parse = (fullForecast, forecastUrl) => {
// get the object to modify/populate
const fDay = forecast[destIndex];
// preload the icon
preloadImg(fDay.icon);
if (period.isDaytime) {
// day time is the high temperature
fDay.high = period.temperature;
fDay.icon = getLargeIcon(period.icon);
fDay.text = shortenExtendedForecastText(period.shortForecast);
fDay.dayName = dates[destIndex];
// preload the icon
preloadImg(fDay.icon);
// Wait for the corresponding night period to increment
} else {
// low temperature

View File

@@ -172,6 +172,7 @@ class WeatherDisplay {
if (this.screenIndex < 0) this.screenIndex = 0;
if (this.okToDrawCurrentDateTime) this.drawCurrentDateTime();
if (this.okToDrawCurrentConditions) postMessage({ type: 'current-weather-scroll', method: 'start' });
if (!this.okToDrawCurrentConditions) postMessage({ type: 'current-weather-scroll', method: 'non-display' });
if (this.okToDrawCurrentConditions === false) postMessage({ type: 'current-weather-scroll', method: 'hide' });
}