summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
author2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-20 15:47:44 +1000
committer2 * r + 2 * t <61896496+soramanew@users.noreply.github.com>2025-09-20 15:47:44 +1000
commit89d46c1b2fd1a35a3229511f745205ac4956bf9e (patch)
treeaa5c7faed9c627b6933cdc533b540eb695af9dd9 /services
parentsidebar/notifs: sort groups by latest notif (diff)
downloadcaelestia-shell-89d46c1b2fd1a35a3229511f745205ac4956bf9e.tar.gz
caelestia-shell-89d46c1b2fd1a35a3229511f745205ac4956bf9e.tar.bz2
caelestia-shell-89d46c1b2fd1a35a3229511f745205ac4956bf9e.zip
sidebar/notifs: better anims + misc fixes
Diffstat (limited to 'services')
-rw-r--r--services/Notifs.qml113
1 files changed, 91 insertions, 22 deletions
diff --git a/services/Notifs.qml b/services/Notifs.qml
index cb52bc5..7136959 100644
--- a/services/Notifs.qml
+++ b/services/Notifs.qml
@@ -12,17 +12,23 @@ import QtQuick
Singleton {
id: root
- readonly property list<Notif> list: []
+ property list<Notif> list: []
+ readonly property list<Notif> notClosed: list.filter(n => !n.closed)
readonly property list<Notif> popups: list.filter(n => n.popup)
property alias dnd: props.dnd
property bool loaded
onListChanged: {
- if (!loaded)
- return;
+ if (loaded)
+ saveTimer.restart();
+ }
+
+ Timer {
+ id: saveTimer
- storage.setText(JSON.stringify(list.filter(n => !n.closed).map(n => ({
+ interval: 1000
+ onTriggered: storage.setText(JSON.stringify(root.notClosed.map(n => ({
time: n.time,
id: n.id,
summary: n.summary,
@@ -35,7 +41,7 @@ Singleton {
resident: n.resident,
hasActionIcons: n.hasActionIcons,
actions: n.actions
- }))));
+ }))))
}
PersistentProperties {
@@ -60,10 +66,11 @@ Singleton {
onNotification: notif => {
notif.tracked = true;
- root.list.push(notifComp.createObject(root, {
+ const comp = notifComp.createObject(root, {
popup: !props.dnd && ![...Visibilities.screens.values()].some(v => v.sidebar),
notification: notif
- }));
+ });
+ root.list = [comp, ...root.list];
}
}
@@ -75,6 +82,7 @@ Singleton {
const data = JSON.parse(text());
for (const notif of data)
root.list.push(notifComp.createObject(root, notif));
+ root.list.sort((a, b) => a.time - b.time);
root.loaded = true;
}
onLoadFailed: err => {
@@ -140,21 +148,17 @@ Singleton {
}
property Notification notification
- property string id: notification?.id ?? ""
- property string summary: notification?.summary ?? ""
- property string body: notification?.body ?? ""
- property string appIcon: notification?.appIcon ?? ""
- property string appName: notification?.appName ?? ""
- property string image: notification?.image ?? ""
- property real expireTimeout: notification?.expireTimeout ?? Config.notifs.defaultExpireTimeout
- property int urgency: notification?.urgency ?? NotificationUrgency.Normal
- property bool resident: notification?.resident ?? false
- property bool hasActionIcons: notification?.hasActionIcons ?? false
- property list<var> actions: notification?.actions.map(a => ({
- identifier: a.identifier,
- text: a.text,
- invoke: () => a.invoke()
- })) ?? []
+ property string id
+ property string summary
+ property string body
+ property string appIcon
+ property string appName
+ property string image
+ property real expireTimeout: Config.notifs.defaultExpireTimeout
+ property int urgency: NotificationUrgency.Normal
+ property bool resident
+ property bool hasActionIcons
+ property list<var> actions
readonly property Timer timer: Timer {
running: true
@@ -171,6 +175,50 @@ Singleton {
function onClosed(): void {
notif.close();
}
+
+ function onSummaryChanged(): void {
+ notif.summary = notif.notification.summary;
+ }
+
+ function onBodyChanged(): void {
+ notif.body = notif.notification.body;
+ }
+
+ function onAppIconChanged(): void {
+ notif.appIcon = notif.notification.appIcon;
+ }
+
+ function onAppNameChanged(): void {
+ notif.appName = notif.notification.appName;
+ }
+
+ function onImageChanged(): void {
+ notif.image = notif.notification.image;
+ }
+
+ function onExpireTimeoutChanged(): void {
+ notif.expireTimeout = notif.notification.expireTimeout;
+ }
+
+ function onUrgencyChanged(): void {
+ notif.urgency = notif.notification.urgency;
+ }
+
+ function onResidentChanged(): void {
+ notif.resident = notif.notification.resident;
+ }
+
+ function onHasActionIconsChanged(): void {
+ notif.hasActionIcons = notif.notification.hasActionIcons;
+ }
+
+ function onActionsChanged(): void {
+ notif.actions = notif.notification.actions.map(a => ({
+ identifier: a.identifier,
+ text: a.text,
+ invoke: () => a.invoke()
+ }));
+ }
}
function lock(item: Item): void {
@@ -195,6 +243,27 @@ Singleton {
destroy();
}
}
+
+ Component.onCompleted: {
+ if (!notification)
+ return;
+
+ id = notification.id;
+ summary = notification.summary;
+ body = notification.body;
+ appIcon = notification.appIcon;
+ appName = notification.appName;
+ image = notification.image;
+ expireTimeout = notification.expireTimeout;
+ urgency = notification.urgency;
+ resident = notification.resident;
+ hasActionIcons = notification.hasActionIcons;
+ actions = notification.actions.map(a => ({
+ identifier: a.identifier,
+ text: a.text,
+ invoke: () => a.invoke()
+ }));
+ }
}
Component {