| Index: lib/notificationHelper.js |
| diff --git a/lib/notificationHelper.js b/lib/notificationHelper.js |
| index ebfd7d3161d310820e6f46c51e60322025b52138..9431df979be7a209008bddb66b33f17fa5654c6d 100644 |
| --- a/lib/notificationHelper.js |
| +++ b/lib/notificationHelper.js |
| @@ -17,7 +17,7 @@ |
| /** @module notificationHelper */ |
| -let {startIconAnimation, stopIconAnimation} = require("icon"); |
| +let {loadImage, startIconAnimation, stopIconAnimation} = require("icon"); |
| let {Utils} = require("utils"); |
| let {Notification: NotificationStorage} = require("notification"); |
| let {stringifyURL} = require("url"); |
| @@ -154,18 +154,10 @@ function notificationClosed() |
| function imgToBase64(url, callback) |
|
Sebastian Noack
2016/01/23 14:04:10
Since you return a promise now, the callback param
kzar
2016/01/23 14:43:14
Acknowledged.
|
| { |
| - let canvas = document.createElement("canvas"), |
| - ctx = canvas.getContext("2d"), |
| - img = new Image; |
| - img.src = url; |
| - img.onload = function() |
| + return loadImage(url).then(function(canvas) |
| { |
| - canvas.height = img.height; |
| - canvas.width = img.width; |
| - ctx.drawImage(img, 0, 0); |
| - callback(canvas.toDataURL("image/png")); |
| - canvas = null; |
| - }; |
| + return canvas.toDataURL("image/png"); |
|
Sebastian Noack
2016/01/23 14:04:10
Perhaps, we can simply get rid of this helper func
kzar
2016/01/23 14:43:14
Done.
|
| + }); |
| } |
| function initChromeNotifications() |
| @@ -217,7 +209,7 @@ function showNotification(notification) |
| priority: 2 // We use the highest priority to prevent the notification from closing automatically |
| }; |
| - imgToBase64(iconUrl, function(iconData) |
| + imgToBase64(iconUrl).then(function(iconData) |
| { |
| opts.iconUrl = iconData; |
| chrome.notifications.create("", opts, function() {}); |
| @@ -228,7 +220,7 @@ function showNotification(notification) |
| if (linkCount > 0) |
| message += " " + ext.i18n.getMessage("notification_without_buttons"); |
| - imgToBase64(iconUrl, function(iconData) |
| + imgToBase64(iconUrl).then(function(iconData) |
| { |
| let notification = new Notification( |
| title, |