Commit a9d29d87 authored by Dave Barker's avatar Dave Barker 🐈

Refs #82 - Refactor the notifications.clicked message listener

parent 7befbaf7
Pipeline #83234858 passed with stage
in 1 minute and 3 seconds
......@@ -24,8 +24,7 @@ const {filterStorage} = require("filterStorage");
const {filterNotifier} = require("filterNotifier");
const {isSlowFilter, Matcher} = require("matcher");
const {Notification: NotificationStorage} = require("notification");
const {getActiveNotification, shouldDisplay,
notificationClicked} = require("notificationHelper");
const {getActiveNotification, shouldDisplay} = require("notificationHelper");
const {HitLogger} = require("hitLogger");
const {
Filter, ActiveFilter, InvalidFilter, RegExpFilter
......@@ -472,11 +471,6 @@ port.on("notifications.get", (message, sender) =>
return Object.assign({texts}, notification);
});
port.on("notifications.clicked", (message, sender) =>
{
notificationClicked();
});
port.on("subscriptions.add", (message, sender) =>
{
const subscription = Subscription.fromURL(message.url);
......
......@@ -22,6 +22,7 @@
const {startIconAnimation, stopIconAnimation} = require("./icon");
const info = require("info");
const {Utils} = require("./utils");
const {port} = require("messaging");
const {Prefs} = require("./prefs");
const {Notification: NotificationStorage} =
require("../adblockpluscore/lib/notification");
......@@ -199,9 +200,9 @@ function notificationButtonClick(notificationId, buttonIndex)
openNotificationLinks(notificationId);
break;
case "configure":
showOptions().then(([tab, port]) =>
showOptions().then(([tab, optionsPort]) =>
{
port.postMessage({
optionsPort.postMessage({
type: "app.respond",
action: "focusSection",
args: ["notifications"]
......@@ -422,15 +423,16 @@ exports.isOptional = notificationType =>
return !["critical", "relentless"].includes(notificationType);
};
let notificationClicked =
/**
* Tidies up after the currently active notification was clicked.
*/
exports.notificationClicked = () =>
port.on("notifications.clicked", (message, sender) =>
{
if (activeNotification)
notificationDismissed(activeNotification.id, true);
};
if (message.link)
openNotificationLink(message.link);
if (browserNotificationsSupported)
browser.notifications.clear(message.id);
notificationDismissed(message.id, true);
});
ext.pages.onLoading.addListener(page =>
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment