Prevent weather icon flicker
This commit is contained in:
@@ -194,6 +194,12 @@ function currentIcon(current, fallback) {
|
||||
return fallback || ""
|
||||
}
|
||||
|
||||
// wttr.in has no day/night flag. Use its icon only to fill an empty initial
|
||||
// state, never to replace a day/night-aware icon resolved by Open-Meteo.
|
||||
function provisionalCurrentIcon(current, resolvedIcon) {
|
||||
return resolvedIcon || currentIcon(current, "")
|
||||
}
|
||||
|
||||
function weatherResponseCompletesSave(hasConfiguredCoordinates, source) {
|
||||
return hasConfiguredCoordinates ? source === "open-meteo" : source === "wttr"
|
||||
}
|
||||
@@ -290,6 +296,7 @@ if (typeof module !== "undefined") {
|
||||
openMeteoForecastDays: openMeteoForecastDays,
|
||||
openMeteoCurrentCondition: openMeteoCurrentCondition,
|
||||
currentIcon: currentIcon,
|
||||
provisionalCurrentIcon: provisionalCurrentIcon,
|
||||
weatherResponseCompletesSave: weatherResponseCompletesSave,
|
||||
wttrNextForecastDays: wttrNextForecastDays,
|
||||
buildForecastDays: buildForecastDays,
|
||||
|
||||
@@ -315,7 +315,7 @@ Panel {
|
||||
var parsed = JSON.parse(raw)
|
||||
root.report = parsed
|
||||
if (!root.hasConfiguredCoordinates)
|
||||
root.label = Model.currentIcon(parsed.current_condition && parsed.current_condition[0], root.label)
|
||||
root.label = Model.provisionalCurrentIcon(parsed.current_condition && parsed.current_condition[0], root.label)
|
||||
root.forecastRetries = 0
|
||||
if (Model.weatherResponseCompletesSave(root.hasConfiguredCoordinates, "wttr"))
|
||||
root.finishSavingLocation()
|
||||
|
||||
Reference in New Issue
Block a user