mirror of
https://github.com/transmission/transmission
synced 2024-12-26 09:37:56 +00:00
fix: crash on launch from tapping on a notification (#5280)
This commit is contained in:
parent
a216bd7cec
commit
1b81883e66
1 changed files with 19 additions and 3 deletions
|
@ -884,10 +884,24 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
andEventID:kAEOpenContents];
|
andEventID:kAEOpenContents];
|
||||||
|
|
||||||
//if we were opened from a user notification, do the corresponding action
|
//if we were opened from a user notification, do the corresponding action
|
||||||
NSUserNotification* launchNotification = notification.userInfo[NSApplicationLaunchUserNotificationKey];
|
if (@available(macOS 10.14, *))
|
||||||
if (launchNotification)
|
|
||||||
{
|
{
|
||||||
[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
|
//auto importing
|
||||||
|
@ -2385,6 +2399,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
{
|
{
|
||||||
if (!response.notification.request.content.userInfo.count)
|
if (!response.notification.request.content.userInfo.count)
|
||||||
{
|
{
|
||||||
|
completionHandler();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2396,6 +2411,7 @@ void onTorrentCompletenessChanged(tr_torrent* tor, tr_completeness status, bool
|
||||||
{
|
{
|
||||||
[self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo];
|
[self didActivateNotificationByActionShowWithUserInfo:response.notification.request.content.userInfo];
|
||||||
}
|
}
|
||||||
|
completionHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification
|
- (void)userNotificationCenter:(NSUserNotificationCenter*)center didActivateNotification:(NSUserNotification*)notification
|
||||||
|
|
Loading…
Reference in a new issue