From cdd269697bcf1b470da2152bccde27499f5667ef Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Sat, 9 May 2020 23:43:30 -0700 Subject: [PATCH] Shell Notifications: bail early for exact repeats Instead of poking around with private implementation details, skip passing exact repeats to the notification source and let it handle the rest as it normally would. --- src/shell/notification.js | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/shell/notification.js b/src/shell/notification.js index d94b8949c..f30961699 100644 --- a/src/shell/notification.js +++ b/src/shell/notification.js @@ -217,30 +217,27 @@ const Source = GObject.registerClass({ } } - // Check if this is a repeat - let exactRepeat = false; let notification = this._notifications[localId]; + // Check if this is a repeat if (notification) { notification.requestReplyId = requestReplyId; - // Check if @notificationParams represents an exact repeat + // Bail early If @notificationParams represents an exact repeat let title = notificationParams.title.unpack(); let body = notificationParams.body ? - notificationParams.body.unpack() : - null; - - exactRepeat = ( - notification.title === title && - notification.bannerBodyText === body - ); - - if (!exactRepeat) { - notification.title = title; - notification.bannerBodyText = body; - notification.emit('updated', false); + notificationParams.body.unpack() : + null; + + if (notification.title === title && + notification.bannerBodyText === body) { + this._notificationPending = false; + return; } + notification.title = title; + notification.bannerBodyText = body; + // Device Notification } else if (idMatch) { notification = this._createNotification(notificationParams); @@ -265,7 +262,7 @@ const Source = GObject.registerClass({ this._notifications[localId] = notification; } - if (showBanner && !exactRepeat) + if (showBanner) this.showNotification(notification); else this.pushNotification(notification);