Clear notification when the last one is removed
Previously, we switched to not updating the notification popup on a removal, since this usually respawns a new notification popup unexpectedly. However, when the last relevant notification is cleared (ie, by opening/reading the thread before the notification times out and disappears on its own) we should clear the existing popup if there is one. // FREEBIE
This commit is contained in:
parent
1f897f32b7
commit
f7191ad9de
1 changed files with 7 additions and 5 deletions
|
@ -15,6 +15,7 @@
|
||||||
Whisper.Notifications = new (Backbone.Collection.extend({
|
Whisper.Notifications = new (Backbone.Collection.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.on('add', this.onAdd);
|
this.on('add', this.onAdd);
|
||||||
|
this.on('remove', this.onRemove);
|
||||||
},
|
},
|
||||||
onclick: function() {
|
onclick: function() {
|
||||||
var last = this.last();
|
var last = this.last();
|
||||||
|
@ -29,11 +30,6 @@
|
||||||
this.clear();
|
this.clear();
|
||||||
},
|
},
|
||||||
update: function() {
|
update: function() {
|
||||||
if (this.length === 0) {
|
|
||||||
extension.notification.clear();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var setting = storage.get('notification-setting') || 'message';
|
var setting = storage.get('notification-setting') || 'message';
|
||||||
if (setting === SETTINGS.OFF) {
|
if (setting === SETTINGS.OFF) {
|
||||||
return;
|
return;
|
||||||
|
@ -124,6 +120,12 @@
|
||||||
extension.notification.clear();
|
extension.notification.clear();
|
||||||
this.update();
|
this.update();
|
||||||
},
|
},
|
||||||
|
onRemove: function() {
|
||||||
|
if (this.length === 0) {
|
||||||
|
extension.notification.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.reset([]);
|
this.reset([]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue