diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2026-03-12 22:21:05 +1100 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2026-03-12 22:21:05 +1100 |
| commit | 314301157e6f2d9859cc51272b5f8a4f70cc05dd (patch) | |
| tree | a5b1c815f3e37593a9d7a0f9331187c5a37ee0ed /modules/lock/NotifGroup.qml | |
| parent | workspaces: replace reduce with for loop for occupied map (diff) | |
| download | caelestia-shell-314301157e6f2d9859cc51272b5f8a4f70cc05dd.tar.gz caelestia-shell-314301157e6f2d9859cc51272b5f8a4f70cc05dd.tar.bz2 caelestia-shell-314301157e6f2d9859cc51272b5f8a4f70cc05dd.zip | |
notifs: single-pass derived properties in NotifGroup
Diffstat (limited to 'modules/lock/NotifGroup.qml')
| -rw-r--r-- | modules/lock/NotifGroup.qml | 27 |
1 files changed, 24 insertions, 3 deletions
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<var> 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 |