From 999e0847278d578b80ccbd45b8984cb42d43088d Mon Sep 17 00:00:00 2001 From: lilia Date: Tue, 1 Dec 2015 13:52:38 -0800 Subject: [PATCH] Serialize notification updates // FREEBIE --- js/chromium.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/js/chromium.js b/js/chromium.js index 420d5e533..ffa390f7d 100644 --- a/js/chromium.js +++ b/js/chromium.js @@ -180,9 +180,14 @@ } }; + var notification_pending = Promise.resolve(); extension.notification = { 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) { if (chrome) { @@ -195,10 +200,16 @@ items : options.items, buttons : options.buttons }; - chrome.notifications.update('signal', chromeOpts, function(wasUpdated) { - if (!wasUpdated) { - chrome.notifications.create('signal', chromeOpts); - } + notification_pending = notification_pending.then(function() { + return new Promise(function(resolve) { + chrome.notifications.update('signal', chromeOpts, function(wasUpdated) { + if (!wasUpdated) { + chrome.notifications.create('signal', chromeOpts, resolve); + } else { + resolve(); + } + }); + }); }); } else { var notification = new Notification(options.title, {