Use async versions of UNUserNotificationCenterDelegate functions.

This commit is contained in:
Brent Simmons 2024-03-24 12:18:50 -07:00
parent 55d67c3277
commit b94935998b
1 changed files with 16 additions and 21 deletions

View File

@ -481,30 +481,25 @@ import Sparkle
// MARK: UNUserNotificationCenterDelegate // MARK: UNUserNotificationCenterDelegate
nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification) async -> UNNotificationPresentationOptions {
completionHandler([.banner, .badge, .sound])
[.banner, .badge, .sound]
} }
nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) { nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse) async {
let userInfo = response.notification.request.content.userInfo let userInfo = response.notification.request.content.userInfo
guard let articlePathInfo = ArticlePathInfo(userInfo: userInfo) else { guard let articlePathInfo = ArticlePathInfo(userInfo: userInfo) else {
completionHandler()
return return
} }
let actionIdentifier = response.actionIdentifier switch response.actionIdentifier {
Task { @MainActor in
switch actionIdentifier {
case "MARK_AS_READ": case "MARK_AS_READ":
handleMarkAsRead(articlePathInfo: articlePathInfo) await handleMarkAsRead(articlePathInfo: articlePathInfo)
case "MARK_AS_STARRED": case "MARK_AS_STARRED":
handleMarkAsStarred(articlePathInfo: articlePathInfo) await handleMarkAsStarred(articlePathInfo: articlePathInfo)
default: default:
mainWindowController?.handle(articlePathInfo: articlePathInfo) await mainWindowController?.handle(articlePathInfo: articlePathInfo)
}
completionHandler()
} }
} }