Create notifications if window is not focused

Track focus using focus and blur events.

// FREEBIE
This commit is contained in:
lilia 2015-11-01 23:44:15 -08:00
parent 0f023ac4bf
commit 4e2723a751

View file

@ -27,10 +27,12 @@
if (inboxOpened) { if (inboxOpened) {
conversation.trigger('newmessages'); conversation.trigger('newmessages');
extension.windows.drawAttention(inboxWindowId); if (inboxFocused) {
if (!appWindow.isMinimized()) {
return; return;
} }
if (inboxOpened) {
extension.windows.drawAttention(inboxWindowId);
}
} }
if (Whisper.Notifications.isEnabled()) { if (Whisper.Notifications.isEnabled()) {
@ -54,6 +56,7 @@
}; };
/* Inbox window controller */ /* Inbox window controller */
var inboxFocused = false;
var inboxOpened = false; var inboxOpened = false;
var inboxWindowId = 'inbox'; var inboxWindowId = 'inbox';
var appWindow = null; var appWindow = null;
@ -77,6 +80,13 @@
appWindow = null; appWindow = null;
}); });
appWindow.contentWindow.addEventListener('blur', function() {
inboxFocused = false;
});
appWindow.contentWindow.addEventListener('focus', function() {
inboxFocused = true;
});
// close the panel if background.html is refreshed // close the panel if background.html is refreshed
extension.windows.beforeUnload(function() { extension.windows.beforeUnload(function() {
// TODO: reattach after reload instead of closing. // TODO: reattach after reload instead of closing.