From eb1cfe9b7004fff592f61165845406bdc220e4d9 Mon Sep 17 00:00:00 2001 From: lilia Date: Thu, 24 Sep 2015 15:18:31 -0700 Subject: [PATCH] Move notification listeners to background Otherwise they will be re-registered by the frontend page. // FREEBIE --- js/background.js | 19 +++++++++++++++++++ js/chromium.js | 18 ------------------ 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/js/background.js b/js/background.js index 1dac4cde5d..6b28d33e41 100644 --- a/js/background.js +++ b/js/background.js @@ -4,6 +4,25 @@ ;(function() { 'use strict'; + // register some chrome listeners + if (chrome.notifications) { + chrome.notifications.onClicked.addListener(function() { + chrome.notifications.clear('signal'); + Whisper.Notifications.onclick(); + }); + chrome.notifications.onButtonClicked.addListener(function() { + chrome.notifications.clear('signal'); + Whisper.Notifications.clear(); + getInboxCollection().each(function(model) { + model.markRead(); + }); + }); + chrome.notifications.onClosed.addListener(function(id, byUser) { + if (byUser) { + Whisper.Notifications.clear(); + } + }); + } if (chrome && chrome.alarms) { chrome.alarms.onAlarm.addListener(function() { // nothing to do. diff --git a/js/chromium.js b/js/chromium.js index 6d2a4e6ee3..abc9c52326 100644 --- a/js/chromium.js +++ b/js/chromium.js @@ -170,24 +170,6 @@ } }; - if (chrome.notifications) { - chrome.notifications.onClicked.addListener(function() { - chrome.notifications.clear('signal'); - Whisper.Notifications.onclick(); - }); - chrome.notifications.onButtonClicked.addListener(function() { - chrome.notifications.clear('signal'); - Whisper.Notifications.clear(); - getInboxCollection().each(function(model) { - model.markRead(); - }); - }); - chrome.notifications.onClosed.addListener(function(id, byUser) { - if (byUser) { - Whisper.Notifications.clear(); - } - }); - } extension.notify = function(options) { if (chrome) { chrome.notifications.clear('signal');