Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/notificationHelper.js

Issue 29583620: Issue 5354 - Adds handling for notifications on Opera (Closed)
Patch Set: Created Oct. 19, 2017, 9:56 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/notificationHelper.js
===================================================================
--- a/lib/notificationHelper.js
+++ b/lib/notificationHelper.js
@@ -188,25 +188,35 @@
let message = (texts.message || "").replace(/<\/?(a|strong)>/g, "");
let iconUrl = ext.getURL("icons/detailed/abp-128.png");
let linkCount = (activeNotification.links || []).length;
if ("notifications" in chrome)
{
activeButtons = getNotificationButtons(activeNotification.type,
texts.message);
- chrome.notifications.create("", {
+ let options = {
type: "basic",
title,
iconUrl,
message,
buttons: activeButtons.map(button => ({title: button.title})),
// We use the highest priority to prevent the notification
// from closing automatically.
priority: 2
+ };
+ chrome.notifications.create("", options, () =>
+ {
+ if (chrome.runtime.lastError && chrome.runtime.lastError.message === `
+ Adding buttons to notifications is not supported.`)
Sebastian Noack 2017/10/21 21:04:28 I would skip the check for the error message. If i
Jon Sonesen 2017/10/30 22:41:41 Done.
+ {
+ delete options.buttons;
Jon Sonesen 2017/10/19 21:59:17 perhaps it is better to move this down or put all
Sebastian Noack 2017/10/21 21:04:28 Yeah, I guess this operation makes more sense in t
Jon Sonesen 2017/10/30 22:41:41 Done.
+ if (activeNotification.type != "question")
+ chrome.notifications.create("", options);
+ }
});
}
else if ("Notification" in window && activeNotification.type != "question")
{
if (linkCount > 0)
message += " " + ext.i18n.getMessage("notification_without_buttons");
let widget = new Notification(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld