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: adress comments p1, rebase Created Oct. 30, 2017, 10:39 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,38 @@
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.
+ // Question type notfications always include buttons.
+ if (browser.runtime.lastError)
+ {
+ if (activeNotification.type != "question")
Sebastian Noack 2017/10/30 22:46:43 You can just check both conditions in the same if-
Jon Sonesen 2017/11/01 18:21:44 Done.
+ {
+ 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