Serialize notification updates
// FREEBIE
This commit is contained in:
parent
d0b1aa3829
commit
999e084727
1 changed files with 16 additions and 5 deletions
|
@ -180,9 +180,14 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var notification_pending = Promise.resolve();
|
||||||
extension.notification = {
|
extension.notification = {
|
||||||
clear: function() {
|
clear: function() {
|
||||||
chrome.notifications.clear('signal');
|
notification_pending = notification_pending.then(function() {
|
||||||
|
return new Promise(function(resolve) {
|
||||||
|
chrome.notifications.clear('signal', resolve);
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
update: function(options) {
|
update: function(options) {
|
||||||
if (chrome) {
|
if (chrome) {
|
||||||
|
@ -195,11 +200,17 @@
|
||||||
items : options.items,
|
items : options.items,
|
||||||
buttons : options.buttons
|
buttons : options.buttons
|
||||||
};
|
};
|
||||||
|
notification_pending = notification_pending.then(function() {
|
||||||
|
return new Promise(function(resolve) {
|
||||||
chrome.notifications.update('signal', chromeOpts, function(wasUpdated) {
|
chrome.notifications.update('signal', chromeOpts, function(wasUpdated) {
|
||||||
if (!wasUpdated) {
|
if (!wasUpdated) {
|
||||||
chrome.notifications.create('signal', chromeOpts);
|
chrome.notifications.create('signal', chromeOpts, resolve);
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
var notification = new Notification(options.title, {
|
var notification = new Notification(options.title, {
|
||||||
body : options.message,
|
body : options.message,
|
||||||
|
|
Loading…
Reference in a new issue