notifications: add invokeLast ipc to run the newest notification's default action (#3734)

* notifications: add invokeLast ipc to run the newest notification's default action

* notifications: drop the invokeLast test file
This commit is contained in:
Mario Mohar authored and GitHub committed 2026-10-09 15:29:21 -04:00
1 parent aef801fc4b
commit e2a0b37d03
2 files changed
+17

No files matched your search

+6
View File
@@ -190,6 +190,12 @@ DModal {
return "NOTIFICATION_DISMISS_SUCCESS";
}
function invokeLast(): string {
if (!NotificationService.invokeLastNotification())
return "NOTIFICATION_INVOKE_NO_ACTION";
return "NOTIFICATION_INVOKE_SUCCESS";
}
target: "notifications"
}
@@ -1049,6 +1049,17 @@ Singleton {
dismissNotification(w);
}
function invokeLastNotification() {
const w = notifications[notifications.length - 1];
const actions = w?.actions || [];
const action = actions.find(a => a.identifier === "default") || actions[0];
if (!action?.invoke)
return false;
action.invoke();
dismissNotification(w);
return true;
}
function dismissAllPopups() {
for (const w of visibleNotifications) {
if (w) {