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: address p2 comment Created Nov. 1, 2017, 6:21 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
@@ -191,25 +191,35 @@
let message = (texts.message || "").replace(/<\/?(a|strong)>/g, "");
let iconUrl = browser.extension.getURL("icons/detailed/abp-128.png");
let linkCount = (activeNotification.links || []).length;
if ("notifications" in browser)
{
activeButtons = getNotificationButtons(activeNotification.type,
texts.message);
- browser.notifications.create("", {
+ let notificationOptions = {
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
+ };
+ browser.notifications.create("", notificationOptions, () =>
+ {
+ // Opera does not support the addtition of buttons to notifications.
Sebastian Noack 2017/11/01 18:45:03 Typo: addtition
+ // Question type notfications always include buttons.
+ if (browser.runtime.lastError && activeNotification.type != "question")
+ {
+ delete notificationOptions.buttons;
+ browser.notifications.create("", notificationOptions);
+ }
});
}
else if ("Notification" in window && activeNotification.type != "question")
{
if (linkCount > 0)
{
message += " " + browser.i18n.getMessage(
"notification_without_buttons"
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld