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

Unified Diff: lib/notificationHelper.js

Issue 29374674: Issue 4864 - Start using ESLint for adblockpluschrome (Closed)
Patch Set: Addressed Wladimir's feedback Created March 15, 2017, 4:51 a.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 | « lib/messaging.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/notificationHelper.js
diff --git a/lib/notificationHelper.js b/lib/notificationHelper.js
index e4fb84b49fa31a408c2e8949b87f6eb986c048de..b4b47343274c26d39dc3145cac401a3227d12af5 100644
--- a/lib/notificationHelper.js
+++ b/lib/notificationHelper.js
@@ -133,7 +133,8 @@ function notificationButtonClick(buttonIndex)
});
break;
case "question":
- NotificationStorage.triggerQuestionListeners(activeNotification.id, buttonIndex == 0);
+ NotificationStorage.triggerQuestionListeners(activeNotification.id,
+ buttonIndex == 0);
NotificationStorage.markAsShown(activeNotification.id);
activeNotification.onClicked();
break;
@@ -147,10 +148,13 @@ function notificationClosed()
function initChromeNotifications()
{
- // Chrome hides notifications in notification center when clicked so we need to clear them
+ // Chrome hides notifications in notification center when clicked so
+ // we need to clear them.
function clearActiveNotification(notificationId)
{
- if (activeNotification && activeNotification.type != "question" && !("links" in activeNotification))
+ if (activeNotification &&
+ activeNotification.type != "question" &&
+ !("links" in activeNotification))
return;
chrome.notifications.clear(notificationId, wasCleared =>
@@ -160,11 +164,13 @@ function initChromeNotifications()
});
}
- chrome.notifications.onButtonClicked.addListener((notificationId, buttonIndex) =>
- {
- notificationButtonClick(buttonIndex);
- clearActiveNotification(notificationId);
- });
+ chrome.notifications.onButtonClicked.addListener(
+ (notificationId, buttonIndex) =>
+ {
+ notificationButtonClick(buttonIndex);
+ clearActiveNotification(notificationId);
+ }
+ );
chrome.notifications.onClicked.addListener(clearActiveNotification);
chrome.notifications.onClosed.addListener(notificationClosed);
}
@@ -179,20 +185,23 @@ function showNotification(notification)
{
let texts = NotificationStorage.getLocalizedTexts(notification);
let title = texts.title || "";
- let message = texts.message ? texts.message.replace(/<\/?(a|strong)>/g, "") : "";
+ 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);
+ activeButtons = getNotificationButtons(activeNotification.type,
+ texts.message);
chrome.notifications.create("", {
type: "basic",
- title: title,
- iconUrl: iconUrl,
- message: message,
+ title,
+ iconUrl,
+ message,
buttons: activeButtons.map(button => ({title: button.title})),
- priority: 2 // We use the highest priority to prevent the notification from closing automatically
+ // We use the highest priority to prevent the notification
+ // from closing automatically.
+ priority: 2
});
}
else if ("Notification" in window && activeNotification.type != "question")
@@ -200,7 +209,7 @@ function showNotification(notification)
if (linkCount > 0)
message += " " + ext.i18n.getMessage("notification_without_buttons");
- let notification = new Notification(
+ let widget = new Notification(
title,
{
lang: Utils.appLocale,
@@ -210,12 +219,12 @@ function showNotification(notification)
}
);
- notification.addEventListener("click", openNotificationLinks);
- notification.addEventListener("close", notificationClosed);
+ widget.addEventListener("click", openNotificationLinks);
+ widget.addEventListener("close", notificationClosed);
}
else
{
- let message = title + "\n" + message;
+ message = title + "\n" + message;
if (linkCount > 0)
message += "\n\n" + ext.i18n.getMessage("notification_with_buttons");
@@ -230,7 +239,7 @@ function showNotification(notification)
if (notification.type !== "question")
NotificationStorage.markAsShown(notification.id);
-};
+}
/**
* Initializes the notification system.
« no previous file with comments | « lib/messaging.js ('k') | lib/popupBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld