1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 01:27:28 +00:00

fix: crash on launch from tapping on a notification (#5280)

This commit is contained in:
Cœur 2023-03-24 21:04:30 +08:00 committed by GitHub
parent a216bd7cec
commit 1b81883e66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -884,10 +884,24 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
andEventID:kAEOpenContents];
//if we were opened from a user notification, do the corresponding action
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
if (@available(macOS 10.14, *))
{
[self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter didActivateNotification:launchNotification];
UNNotificationResponse* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:UNUserNotificationCenter.currentNotificationCenter
didReceiveNotificationResponse:launchNotification withCompletionHandler:^{
}];
}
}
else
{
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
if (launchNotification)
{
[self userNotificationCenter:NSUserNotificationCenter.defaultUserNotificationCenter
didActivateNotification:launchNotification];
}
}
//auto importing
@ -2385,6 +2399,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
{
if (!response.notification.request.content.userInfo.count)
{
completionHandler();
return;
}
@ -2396,6 +2411,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
{
[self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo];
}
completionHandler();
}
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification