From 314301157e6f2d9859cc51272b5f8a4f70cc05dd Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Thu, 12 Mar 2026 22:21:05 +1100 Subject: notifs: single-pass derived properties in NotifGroup --- modules/lock/NotifGroup.qml | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'modules/lock') diff --git a/modules/lock/NotifGroup.qml b/modules/lock/NotifGroup.qml index 7796090..85c5ec4 100644 --- a/modules/lock/NotifGroup.qml +++ b/modules/lock/NotifGroup.qml @@ -17,9 +17,30 @@ StyledRect { required property string modelData readonly property list notifs: Notifs.list.filter(notif => notif.appName === modelData) - readonly property string image: notifs.find(n => n.image.length > 0)?.image ?? "" - readonly property string appIcon: notifs.find(n => n.appIcon.length > 0)?.appIcon ?? "" - readonly property string urgency: notifs.some(n => n.urgency === NotificationUrgency.Critical) ? "critical" : notifs.some(n => n.urgency === NotificationUrgency.Normal) ? "normal" : "low" + readonly property var props: { + let img = ""; + let icon = ""; + let hasCritical = false; + let hasNormal = false; + for (const n of notifs) { + if (!img && n.image.length > 0) + img = n.image; + if (!icon && n.appIcon.length > 0) + icon = n.appIcon; + if (n.urgency === NotificationUrgency.Critical) + hasCritical = true; + else if (n.urgency === NotificationUrgency.Normal) + hasNormal = true; + } + return { + img, + icon, + urgency: hasCritical ? "critical" : hasNormal ? "normal" : "low" + }; + } + readonly property string image: props.img + readonly property string appIcon: props.icon + readonly property string urgency: props.urgency property bool expanded -- cgit v1.2.3-freya