messageTray: Only connect to a notification's open/destroy once

If we pushNotification the same notification multiple times, we
won't append it to the array again, but we will attach multiple
handlers needlessly.

https://bugzilla.gnome.org/show_bug.cgi?id=710115
This commit is contained in:
Jasper St. Pierre 2013-10-13 21:51:30 -04:00
parent 66a4cb5875
commit 99cf4e5787

View File

@ -1407,10 +1407,8 @@ const Source = new Lang.Class({
}, },
pushNotification: function(notification) { pushNotification: function(notification) {
if (this.notifications.indexOf(notification) < 0) { if (this.notifications.indexOf(notification) >= 0)
this.notifications.push(notification); return;
this.emit('notification-added', notification);
}
notification.connect('clicked', Lang.bind(this, this.open)); notification.connect('clicked', Lang.bind(this, this.open));
notification.connect('destroy', Lang.bind(this, notification.connect('destroy', Lang.bind(this,
@ -1426,6 +1424,9 @@ const Source = new Lang.Class({
this.countUpdated(); this.countUpdated();
})); }));
this.notifications.push(notification);
this.emit('notification-added', notification);
this.countUpdated(); this.countUpdated();
}, },