From a57451d00b047fc5153dac9e9aba898f13a9bd4a Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 15 Sep 2015 18:49:41 -0700 Subject: [PATCH] Show notifications if the window is minimized // FREEBIE --- js/panel_controller.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/panel_controller.js b/js/panel_controller.js index 338826bb8a..7f9c878fb4 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -89,10 +89,16 @@ conversation = conversations.create({id: conversationId}); conversation.fetch(); } + if (inboxOpened) { conversation.trigger('newmessages'); extension.windows.drawAttention(inboxWindowId); - } else if (Whisper.Notifications.isEnabled()) { + if (!appWindow.isMinimized()) { + return; + } + } + + if (Whisper.Notifications.isEnabled()) { var sender = ConversationController.create({id: message.get('source')}); conversation.fetch().then(function() { sender.fetch().then(function() { @@ -116,6 +122,7 @@ /* Inbox window controller */ var inboxOpened = false; var inboxWindowId = 'inbox'; + var appWindow = null; window.openInbox = function() { if (inboxOpened === false) { inboxOpened = true; @@ -131,9 +138,11 @@ minHeight: 150 }, function (windowInfo) { inboxWindowId = windowInfo.id; + appWindow = windowInfo; windowInfo.onClosed.addListener(function () { inboxOpened = false; + appWindow = null; }); // close the panel if background.html is refreshed