diff --git a/js/notifications.js b/js/notifications.js index 140f13dc..985a0f52 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -15,6 +15,7 @@ Whisper.Notifications = new (Backbone.Collection.extend({ initialize: function() { this.on('add', this.onAdd); + this.on('remove', this.onRemove); }, onclick: function() { var last = this.last(); @@ -29,11 +30,6 @@ this.clear(); }, update: function() { - if (this.length === 0) { - extension.notification.clear(); - return; - } - var setting = storage.get('notification-setting') || 'message'; if (setting === SETTINGS.OFF) { return; @@ -124,6 +120,12 @@ extension.notification.clear(); this.update(); }, + onRemove: function() { + if (this.length === 0) { + extension.notification.clear(); + return; + } + }, clear: function() { this.reset([]); }