From 3eafefe18e0728115207d67dc43c95ca131e5465 Mon Sep 17 00:00:00 2001 From: lilia Date: Sun, 24 May 2015 16:19:33 -0700 Subject: [PATCH] Don't display notifications for open windows. Just update and draw attention to them. Fixes #238 // FREEBIE --- js/chromium.js | 4 +++- js/panel_controller.js | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/js/chromium.js b/js/chromium.js index f27f2323..ce2575e7 100644 --- a/js/chromium.js +++ b/js/chromium.js @@ -146,7 +146,9 @@ drawAttention: function(window_id) { if (chrome.app.window) { - chrome.app.window.get(window_id).drawAttention(); + var w = chrome.app.window.get(window_id); + w.clearAttention(); + w.drawAttention(); } } diff --git a/js/panel_controller.js b/js/panel_controller.js index ef1f9e8f..0ad499a5 100644 --- a/js/panel_controller.js +++ b/js/panel_controller.js @@ -48,7 +48,13 @@ }; window.notifyConversation = function(message) { - if (Whisper.Notifications.isEnabled()) { + var conversationId = message.get('conversationId'); + var windowId = windowMap.windowIdFrom(conversationId); + if (windowId) { + // already open + updateConversation(conversationId); + extension.windows.drawAttention(windowId); + } else if (Whisper.Notifications.isEnabled()) { var conversation = getConversation({id: message.get('conversationId')}); var sender = getConversation({id: message.get('source')}); conversation.fetch().then(function() { @@ -65,7 +71,6 @@ }); conversation.fetchMessages(); } else { - var conversationId = message.get('conversationId'); openConversation(conversationId); var windowId = windowMap.windowIdFrom(conversationId); extension.windows.drawAttention(windowId);