Skip to content

Commit 0aa0a98

Browse files
clemensvonmolovchigrin
authored andcommitted
fix outdated constructor call for NotificationItem
1 parent 22b79c8 commit 0aa0a98

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

src/displayapp/screens/Notifications.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ void Notifications::Refresh() {
111111
notification.Message(),
112112
currentIdx + 1,
113113
notification.category,
114+
notification.timeArrived,
115+
std::chrono::system_clock::to_time_t(this->dateTimeController.CurrentDateTime()),
114116
notificationManager.NbNotifications(),
115117
alertNotificationService,
116118
motorController);
@@ -303,24 +305,24 @@ Notifications::NotificationItem::NotificationItem(const char* title,
303305
lv_label_set_text_static(alert_type, "Notification");
304306
} else {
305307
// almost impossible to receive a real notification at time 0, so skip because it is the "no notifications" notification
306-
if(timeNow != 0) {
307-
auto diff = std::chrono::system_clock::from_time_t(timeNow) - std::chrono::system_clock::from_time_t(timeArrived);
308-
std::chrono::minutes age = std::chrono::duration_cast<std::chrono::minutes>(diff);
309-
uint32_t ageInt = static_cast<uint32_t>(age.count());
310-
char timeUnit;
311-
if ((ageInt / (60 * 24)) >= 1) {
312-
ageInt /= (60*24);
313-
timeUnit = 'd';
314-
} else if ((ageInt / 60) >= 1) {
315-
ageInt /= 60;
316-
timeUnit = 'h';
317-
} else {
318-
timeUnit = 'm';
319-
}
320-
lv_obj_t* alert_age = lv_label_create(container1, nullptr);
321-
lv_label_set_text_fmt(alert_age, "%d%c ago",ageInt, timeUnit);
322-
// same format as alert_count
323-
lv_obj_align(alert_age, container1, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -16);
308+
if (timeNow != 0) {
309+
auto diff = std::chrono::system_clock::from_time_t(timeNow) - std::chrono::system_clock::from_time_t(timeArrived);
310+
std::chrono::minutes age = std::chrono::duration_cast<std::chrono::minutes>(diff);
311+
uint32_t ageInt = static_cast<uint32_t>(age.count());
312+
char timeUnit;
313+
if ((ageInt / (60 * 24)) >= 1) {
314+
ageInt /= (60 * 24);
315+
timeUnit = 'd';
316+
} else if ((ageInt / 60) >= 1) {
317+
ageInt /= 60;
318+
timeUnit = 'h';
319+
} else {
320+
timeUnit = 'm';
321+
}
322+
lv_obj_t* alert_age = lv_label_create(container, nullptr);
323+
lv_label_set_text_fmt(alert_age, "%d%c ago", ageInt, timeUnit);
324+
// same format as alert_count
325+
lv_obj_align(alert_age, container, LV_ALIGN_IN_BOTTOM_RIGHT, 0, -16);
324326
}
325327

326328
// copy title to label and replace newlines with spaces

0 commit comments

Comments
 (0)