mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-14 15:49:31 -07:00
fix extended forecast preload close #189
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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' });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user