Skip to content

Commit

Permalink
Shell Notifications: bail early for exact repeats
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
andyholmes committed May 10, 2020
1 parent 3e9391d commit cdd2696
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions src/shell/notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -265,7 +262,7 @@ const Source = GObject.registerClass({
this._notifications[localId] = notification;
}

if (showBanner && !exactRepeat)
if (showBanner)
this.showNotification(notification);
else
this.pushNotification(notification);
Expand Down

0 comments on commit cdd2696

Please sign in to comment.