Don't display notifications for open windows.

Just update and draw attention to them.

Fixes #238

// FREEBIE
This commit is contained in:
lilia 2015-05-24 16:19:33 -07:00
parent d8f17f9631
commit 3eafefe18e
2 changed files with 10 additions and 3 deletions

View file

@ -146,7 +146,9 @@
drawAttention: function(window_id) { drawAttention: function(window_id) {
if (chrome.app.window) { if (chrome.app.window) {
chrome.app.window.get(window_id).drawAttention(); var w = chrome.app.window.get(window_id);
w.clearAttention();
w.drawAttention();
} }
} }

View file

@ -48,7 +48,13 @@
}; };
window.notifyConversation = function(message) { 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 conversation = getConversation({id: message.get('conversationId')});
var sender = getConversation({id: message.get('source')}); var sender = getConversation({id: message.get('source')});
conversation.fetch().then(function() { conversation.fetch().then(function() {
@ -65,7 +71,6 @@
}); });
conversation.fetchMessages(); conversation.fetchMessages();
} else { } else {
var conversationId = message.get('conversationId');
openConversation(conversationId); openConversation(conversationId);
var windowId = windowMap.windowIdFrom(conversationId); var windowId = windowMap.windowIdFrom(conversationId);
extension.windows.drawAttention(windowId); extension.windows.drawAttention(windowId);