Fix various concurrency issues.

This commit is contained in:
Brent Simmons committed 2025-11-18 16:01:37 -08:00
1 parent 8ecba60d71
commit d4dc837d9f
1 file changed
+11 -2
+11 -2
View File
@@ -454,9 +454,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat
nonisolated func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
// Wrapper to safely transfer non-Sendable values to MainActor
struct UnsafeSendable<T>: @unchecked Sendable {
let value: T
}
let wrappedResponse = UnsafeSendable(value: response)
let wrappedCompletionHandler = UnsafeSendable(value: completionHandler)
Task { @MainActor in
let response = wrappedResponse.value
let userInfo = response.notification.request.content.userInfo
switch response.actionIdentifier {
case UserNotificationManager.ActionIdentifier.markAsRead:
handleMarkAsRead(userInfo: userInfo)
@@ -465,7 +474,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSUserInterfaceValidat
default:
mainWindowController?.handle(response)
}
completionHandler()
wrappedCompletionHandler.value()
}
}