From 152272c51a9653743f31a8a81b01d256fe6037c5 Mon Sep 17 00:00:00 2001 From: quadbyte Date: Mon, 11 Aug 2025 18:33:13 -0400 Subject: [PATCH] Location fix timestamp and logic --- Services/Location.qml | 11 ++++++++++- Services/Time.qml | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Services/Location.qml b/Services/Location.qml index 341aefd..94d9e57 100644 --- a/Services/Location.qml +++ b/Services/Location.qml @@ -35,7 +35,7 @@ Singleton { property string latitude: "" property string longitude: "" - property string weatherLastFetch: "" + property int weatherLastFetch: 0 property var weather: null } } @@ -53,6 +53,14 @@ Singleton { function init() {// does nothing but ensure the singleton is created } + // -------------------------------- + function resetWeather() { + data.latitude = "" + data.longitude = "" + data.weatherLastFetch = 0 + data.weather = null + } + // -------------------------------- function updateWeather() { if ((data.weatherLastFetch === "") || (Time.timestamp >= data.weatherLastFetch + weatherUpdateFrequency)) { @@ -107,6 +115,7 @@ Singleton { // -------------------------------- function _fetchWeather(latitude, longitude, errorCallback) { + console.log("Getting weather") var url = "https://api.open-meteo.com/v1/forecast?latitude=" + latitude + "&longitude=" + longitude + "¤t_weather=true¤t=relativehumidity_2m,surface_pressure&daily=temperature_2m_max,temperature_2m_min,weathercode&timezone=auto" var xhr = new XMLHttpRequest() diff --git a/Services/Time.qml b/Services/Time.qml index 3d827ad..0ce3593 100644 --- a/Services/Time.qml +++ b/Services/Time.qml @@ -39,7 +39,7 @@ Singleton { } // Returns a Unix Timestamp (in seconds) - readonly property string timestamp: { + readonly property int timestamp: { return Math.floor(Date.now() / 1000) }