Add *some* closed events to cocoa notifications

This commit is contained in:
Kovid Goyal
2024-07-27 13:47:31 +05:30
parent 66b466d93a
commit 706cf1cd24
3 changed files with 33 additions and 28 deletions

View File

@@ -421,18 +421,20 @@ class MacOSIntegration(DesktopIntegration):
cocoa_send_notification(str(desktop_notification_id), title, body or ' ', subtitle, urgency.value)
return desktop_notification_id
def notification_activated(self, ident: str, activated: bool) -> None:
def notification_activated(self, event: str, ident: str) -> None:
if debug_desktop_integration:
log_error(f'Notification {ident} {activated=}')
log_error(f'Notification {ident} {event=}')
try:
desktop_notification_id = int(ident)
except Exception:
log_error(f'Got unexpected notification activated event with id: {ident!r} from cocoa')
else:
if activated:
self.notification_manager.notification_activated(desktop_notification_id)
else:
self.notification_manager.notification_closed(desktop_notification_id)
return
if event == "created":
self.notification_manager.notification_created(desktop_notification_id)
elif event == "activated":
self.notification_manager.notification_activated(desktop_notification_id)
elif event == "closed":
self.notification_manager.notification_closed(desktop_notification_id)
class FreeDesktopIntegration(DesktopIntegration):