From aa892fceabeeef4fd56e1727310875f8d734c11e Mon Sep 17 00:00:00 2001 From: Olaf Luijks Date: Fri, 28 Nov 2025 09:55:07 +0100 Subject: [PATCH] fix(notifications): harden history date tabs for empty lists --- .../NotificationHistoryPanel.qml | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/Modules/Panels/NotificationHistory/NotificationHistoryPanel.qml b/Modules/Panels/NotificationHistory/NotificationHistoryPanel.qml index 7feec0d9..1ab4497f 100644 --- a/Modules/Panels/NotificationHistory/NotificationHistoryPanel.qml +++ b/Modules/Panels/NotificationHistory/NotificationHistoryPanel.qml @@ -16,6 +16,7 @@ SmartPanel { // 0 = All, 1 = Today, 2 = Yesterday, 3 = Earlier property int currentRange: 1 // start on Today by default property var rangeCounts: [0, 0, 0, 0] + property bool groupByDate: true function dateOnly(d) { return new Date(d.getFullYear(), d.getMonth(), d.getDate()); @@ -44,14 +45,21 @@ SmartPanel { function recalcRangeCounts() { var m = NotificationService.historyList; + if (!m || typeof m.count === "undefined" || m.count <= 0) { + rangeCounts = [0, 0, 0, 0]; + return; + } + var counts = [0, 0, 0, 0]; counts[0] = m.count; for (var i = 0; i < m.count; ++i) { var item = m.get(i); - var r = rangeForTimestamp(item.timestamp); - counts[r + 1] = counts[r + 1] + 1; + if (!item || typeof item.timestamp === "undefined") + continue; + var r = rangeForTimestamp(item.timestamp); // 0..2 + counts[r + 1] = counts[r + 1] + 1; // shift by +1 } rangeCounts = counts; @@ -161,15 +169,15 @@ SmartPanel { text: { if (rangeId === 0) return I18n.tr("notifications.range.all") + - " (" + root.countForRange(rangeId) + ")"; + " (" + root.countForRange(rangeId) + ")"; else if (rangeId === 1) return I18n.tr("notifications.range.today") + - " (" + root.countForRange(rangeId) + ")"; + " (" + root.countForRange(rangeId) + ")"; else if (rangeId === 2) return I18n.tr("notifications.range.yesterday") + - " (" + root.countForRange(rangeId) + ")"; + " (" + root.countForRange(rangeId) + ")"; return I18n.tr("notifications.range.earlier") + - " (" + root.countForRange(rangeId) + ")"; + " (" + root.countForRange(rangeId) + ")"; } Layout.fillWidth: true @@ -179,11 +187,11 @@ SmartPanel { outlined: false backgroundColor: isActive - ? Color.mPrimary - : (hovered ? Color.mHover : Color.transparent) + ? Color.mPrimary + : (hovered ? Color.mHover : Color.transparent) textColor: isActive - ? Color.mOnPrimary - : (hovered ? Color.mOnHover : Color.mOnSurface) + ? Color.mOnPrimary + : (hovered ? Color.mOnHover : Color.mOnSurface) hoverColor: backgroundColor Behavior on backgroundColor { @@ -197,6 +205,7 @@ SmartPanel { } } + // Empty state when no notifications ColumnLayout { Layout.fillWidth: true