Move chrome-specific calls to chromium.js
// FREEBIE
This commit is contained in:
parent
b1afb79a14
commit
6dcff46e26
2 changed files with 27 additions and 20 deletions
|
@ -9,29 +9,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('background page reloaded');
|
console.log('background page reloaded');
|
||||||
// register some chrome listeners
|
extension.notification.init();
|
||||||
if (chrome.notifications) {
|
|
||||||
chrome.notifications.onClicked.addListener(function() {
|
|
||||||
extension.notification.clear();
|
|
||||||
Whisper.Notifications.onclick();
|
|
||||||
});
|
|
||||||
chrome.notifications.onButtonClicked.addListener(function() {
|
|
||||||
extension.notification.clear();
|
|
||||||
Whisper.Notifications.clear();
|
|
||||||
getInboxCollection().each(function(model) {
|
|
||||||
model.markRead();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
chrome.notifications.onClosed.addListener(function(id, byUser) {
|
|
||||||
if (byUser) {
|
|
||||||
Whisper.Notifications.clear();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close and reopen existing windows
|
// Close and reopen existing windows
|
||||||
var open = false;
|
var open = false;
|
||||||
chrome.app.window.getAll().forEach(function(appWindow) {
|
extension.windows.getAll().forEach(function(appWindow) {
|
||||||
open = true;
|
open = true;
|
||||||
appWindow.close();
|
appWindow.close();
|
||||||
});
|
});
|
||||||
|
|
|
@ -105,6 +105,10 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getAll: function() {
|
||||||
|
return chrome.app.window.getAll();
|
||||||
|
},
|
||||||
|
|
||||||
getViews: function() {
|
getViews: function() {
|
||||||
if (chrome.extension) {
|
if (chrome.extension) {
|
||||||
return chrome.extension.getViews();
|
return chrome.extension.getViews();
|
||||||
|
@ -214,6 +218,27 @@
|
||||||
|
|
||||||
var notification_pending = Promise.resolve();
|
var notification_pending = Promise.resolve();
|
||||||
extension.notification = {
|
extension.notification = {
|
||||||
|
init: function() {
|
||||||
|
// register some chrome listeners
|
||||||
|
if (chrome.notifications) {
|
||||||
|
chrome.notifications.onClicked.addListener(function() {
|
||||||
|
extension.notification.clear();
|
||||||
|
Whisper.Notifications.onclick();
|
||||||
|
});
|
||||||
|
chrome.notifications.onButtonClicked.addListener(function() {
|
||||||
|
extension.notification.clear();
|
||||||
|
Whisper.Notifications.clear();
|
||||||
|
getInboxCollection().each(function(model) {
|
||||||
|
model.markRead();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
chrome.notifications.onClosed.addListener(function(id, byUser) {
|
||||||
|
if (byUser) {
|
||||||
|
Whisper.Notifications.clear();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
notification_pending = notification_pending.then(function() {
|
notification_pending = notification_pending.then(function() {
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
|
|
Loading…
Reference in a new issue