notif actions

This commit is contained in:
end-4
2025-04-19 21:38:33 +02:00
parent 3b2628fbd7
commit 3677873a05
4 changed files with 109 additions and 17 deletions
+17 -2
View File
@@ -19,7 +19,7 @@ Singleton {
NotificationServer {
id: notifServer
// actionIconsSupported: true
// actionsSupported: true
actionsSupported: true
bodyHyperlinksSupported: true
// bodyImagesSupported: true
bodyMarkupSupported: true
@@ -32,7 +32,12 @@ Singleton {
notification.tracked = true
const newNotifObject = {
"id": notification.id,
"actions": [],
"actions": notification.actions.map((action) => {
return {
"identifier": action.identifier,
"text": action.text,
}
}),
"appIcon": notification.appIcon,
"appName": notification.appName,
"body": notification.body,
@@ -60,6 +65,16 @@ Singleton {
root.discard(id);
}
function attemptInvokeAction(id, notifIdentifier) {
const notifServerIndex = notifServer.trackedNotifications.values.findIndex((notif) => notif.id === id);
if (notifServerIndex !== -1) {
const notifServerNotif = notifServer.trackedNotifications.values[notifServerIndex];
const action = notifServerNotif.actions.find((action) => action.identifier === notifIdentifier);
action.invoke()
} else console.log("Notification not found in server: " + id)
root.discard(id);
}
function triggerListChange() {
root.list = root.list.slice(0)
}