MCPcopy Index your code
hub / github.com/MagicMirrorOrg/MagicMirror / updateAvailable

Function updateAvailable

defaultmodules/weather/weather.js:276–305  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

274
275 // What to do when the weather provider has new information available?
276 updateAvailable () {
277 Log.log("[weather] New weather information available.");
278 if (window.updateWeatherTheme) {
279 window.updateWeatherTheme(this);
280 } else {
281 this.updateDom(300);
282 }
283
284 const currentWeather = this.currentWeatherObject;
285
286 if (currentWeather) {
287 this.sendNotification("CURRENTWEATHER_TYPE", { type: currentWeather.weatherType?.replace("-", "_") });
288 }
289
290 const notificationPayload = {
291 currentWeather: this.config.units === "imperial"
292 ? WeatherUtils.convertWeatherObjectToImperial(currentWeather?.simpleClone()) ?? null
293 : currentWeather?.simpleClone() ?? null,
294 forecastArray: this.config.units === "imperial"
295 ? this.getForecastArray()?.map((ar) => WeatherUtils.convertWeatherObjectToImperial(ar.simpleClone())) ?? []
296 : this.getForecastArray()?.map((ar) => ar.simpleClone()) ?? [],
297 hourlyArray: this.config.units === "imperial"
298 ? this.getHourlyArray()?.map((ar) => WeatherUtils.convertWeatherObjectToImperial(ar.simpleClone())) ?? []
299 : this.getHourlyArray()?.map((ar) => ar.simpleClone()) ?? [],
300 locationName: this.fetchedLocationName,
301 providerName: this.config.weatherProvider
302 };
303
304 this.sendNotification("WEATHER_UPDATED", notificationPayload);
305 },
306
307 getForecastArray () {
308 return this.weatherForecastArray;

Callers

nothing calls this directly

Calls 3

updateDomMethod · 0.80
sendNotificationMethod · 0.80
simpleCloneMethod · 0.80

Tested by

no test coverage detected