summaryrefslogtreecommitdiff
path: root/services/Weather.qml
diff options
context:
space:
mode:
Diffstat (limited to 'services/Weather.qml')
-rw-r--r--services/Weather.qml12
1 files changed, 5 insertions, 7 deletions
diff --git a/services/Weather.qml b/services/Weather.qml
index 02458c2..f3147a8 100644
--- a/services/Weather.qml
+++ b/services/Weather.qml
@@ -8,7 +8,7 @@ import QtQuick
Singleton {
id: root
- property string loc
+ property string city
property var cc
property var forecast
readonly property string icon: cc ? Icons.getWeatherIcon(cc.weatherCode) : "cloud_alert"
@@ -19,22 +19,20 @@ Singleton {
function reload(): void {
if (Config.services.weatherLocation)
- loc = Config.services.weatherLocation;
- else if (!loc || timer.elapsed() > 900)
+ city = Config.services.weatherLocation;
+ else if (!city || timer.elapsed() > 900)
Requests.get("https://ipinfo.io/json", text => {
- loc = JSON.parse(text).loc ?? "";
+ city = JSON.parse(text).city ?? "";
timer.restart();
});
}
- onLocChanged: Requests.get(`https://wttr.in/${loc}?format=j1`, text => {
+ onCityChanged: Requests.get(`https://wttr.in/${city}?format=j1`, text => {
const json = JSON.parse(text);
cc = json.current_condition[0];
forecast = json.weather;
})
- Component.onCompleted: reload()
-
ElapsedTimer {
id: timer
}