fix: reply notifs sometimes destroyed too early (#25086)
* fix: reply notifs sometimes destroyed too early * Fix windows build
This commit is contained in:
parent
a23c66e4e1
commit
bea6c9e4e1
4 changed files with 10 additions and 5 deletions
|
@ -43,7 +43,10 @@
|
||||||
// https://developer.apple.com/documentation/foundation/nsusernotificationactivationtype?language=objc
|
// https://developer.apple.com/documentation/foundation/nsusernotificationactivationtype?language=objc
|
||||||
if (notif.activationType ==
|
if (notif.activationType ==
|
||||||
NSUserNotificationActivationTypeContentsClicked) {
|
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 ==
|
} else if (notif.activationType ==
|
||||||
NSUserNotificationActivationTypeActionButtonClicked) {
|
NSUserNotificationActivationTypeActionButtonClicked) {
|
||||||
notification->NotificationActivated();
|
notification->NotificationActivated();
|
||||||
|
|
|
@ -21,9 +21,11 @@ Notification::~Notification() {
|
||||||
delegate()->NotificationDestroyed();
|
delegate()->NotificationDestroyed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::NotificationClicked() {
|
void Notification::NotificationClicked(bool should_destroy) {
|
||||||
if (delegate())
|
if (delegate())
|
||||||
delegate()->NotificationClick();
|
delegate()->NotificationClick();
|
||||||
|
|
||||||
|
if (should_destroy)
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class Notification {
|
||||||
virtual void Dismiss() = 0;
|
virtual void Dismiss() = 0;
|
||||||
|
|
||||||
// Should be called by derived classes.
|
// Should be called by derived classes.
|
||||||
void NotificationClicked();
|
void NotificationClicked(bool should_destroy = true);
|
||||||
void NotificationDismissed();
|
void NotificationDismissed();
|
||||||
void NotificationFailed();
|
void NotificationFailed();
|
||||||
|
|
||||||
|
|
|
@ -476,7 +476,7 @@ IFACEMETHODIMP ToastEventHandler::Invoke(
|
||||||
IInspectable* args) {
|
IInspectable* args) {
|
||||||
base::PostTask(
|
base::PostTask(
|
||||||
FROM_HERE, {content::BrowserThread::UI},
|
FROM_HERE, {content::BrowserThread::UI},
|
||||||
base::BindOnce(&Notification::NotificationClicked, notification_));
|
base::BindOnce(&Notification::NotificationClicked, notification_, true));
|
||||||
if (IsDebuggingNotifications())
|
if (IsDebuggingNotifications())
|
||||||
LOG(INFO) << "Notification clicked";
|
LOG(INFO) << "Notification clicked";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue