Skip to content

Commit

Permalink
fix: reply notifs sometimes destroyed too early
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Aug 21, 2020
1 parent 5d33017 commit 1609a7d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Expand Up @@ -43,7 +43,10 @@ - (void)userNotificationCenter:(NSUserNotificationCenter*)center
// https://developer.apple.com/documentation/foundation/nsusernotificationactivationtype?language=objc
if (notif.activationType ==
NSUserNotificationActivationTypeContentsClicked) {
notification->NotificationClicked();
// If a notification with a reply button is clicked and the user has not
// yet replied, we do not want to destroy the notification.
bool should_destroy = ![notif hasReplyButton];
notification->NotificationClicked(should_destroy);
} else if (notif.activationType ==
NSUserNotificationActivationTypeActionButtonClicked) {
notification->NotificationActivated();
Expand Down
6 changes: 4 additions & 2 deletions shell/browser/notifications/notification.cc
Expand Up @@ -21,10 +21,12 @@ Notification::~Notification() {
delegate()->NotificationDestroyed();
}

void Notification::NotificationClicked() {
void Notification::NotificationClicked(bool should_destroy) {
if (delegate())
delegate()->NotificationClick();
Destroy();

if (should_destroy)
Destroy();
}

void Notification::NotificationDismissed() {
Expand Down
2 changes: 1 addition & 1 deletion shell/browser/notifications/notification.h
Expand Up @@ -54,7 +54,7 @@ class Notification {
virtual void Dismiss() = 0;

// Should be called by derived classes.
void NotificationClicked();
void NotificationClicked(bool should_destroy = true);
void NotificationDismissed();
void NotificationFailed();

Expand Down

0 comments on commit 1609a7d

Please sign in to comment.