From f7191ad9dea51572137229fa9a57526374ff3143 Mon Sep 17 00:00:00 2001 From: lilia Date: Mon, 22 Feb 2016 12:55:19 -0800 Subject: [PATCH] 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 --- js/notifications.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/js/notifications.js b/js/notifications.js index 140f13dc94..985a0f5291 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([]); }