summaryrefslogtreecommitdiff
path: root/modules/lock/WeatherInfo.qml
diff options
context:
space:
mode:
Diffstat (limited to 'modules/lock/WeatherInfo.qml')
-rw-r--r--modules/lock/WeatherInfo.qml29
1 files changed, 5 insertions, 24 deletions
diff --git a/modules/lock/WeatherInfo.qml b/modules/lock/WeatherInfo.qml
index 9da0b9b..b2b4579 100644
--- a/modules/lock/WeatherInfo.qml
+++ b/modules/lock/WeatherInfo.qml
@@ -122,31 +122,14 @@ ColumnLayout {
Repeater {
model: {
- const forecast = Weather.forecast;
- let count = root.width < 320 ? 3 : root.width < 400 ? 4 : 5;
+ const forecast = Weather.hourlyForecast;
+ const count = root.width < 320 ? 3 : root.width < 400 ? 4 : 5;
if (!forecast)
return Array.from({
length: count
}, () => null);
- const hours = [];
- const hour = new Date().getHours();
-
- const today = forecast[0].hourly;
- const arr = [...today, ...forecast[1].hourly];
- for (let i = 0; i < arr.length; i++) {
- const time = parseInt(arr[i].time, 10) / 100;
-
- if (i > today.length ? time < hour : time > hour) {
- hours.push(arr[i]);
- count--;
- }
-
- if (count === 0)
- break;
- }
-
- return hours;
+ return forecast.slice(0, count);
}
ColumnLayout {
@@ -160,9 +143,7 @@ ColumnLayout {
StyledText {
Layout.fillWidth: true
text: {
- if (!forecastHour.modelData)
- return "00 AM";
- const hour = parseInt(forecastHour.modelData.time, 10) / 100;
+ const hour = forecastHour.modelData?.hour ?? 0;
return hour > 12 ? `${(hour - 12).toString().padStart(2, "0")} PM` : `${hour.toString().padStart(2, "0")} AM`;
}
color: Colours.palette.m3outline
@@ -172,7 +153,7 @@ ColumnLayout {
MaterialIcon {
Layout.alignment: Qt.AlignHCenter
- text: forecastHour.modelData ? Icons.getWeatherIcon(forecastHour.modelData.weatherCode) : "cloud_alert"
+ text: forecastHour.modelData?.icon ?? "cloud_alert"
font.pointSize: Appearance.font.size.extraLarge * 1.5
font.weight: 500
}