From 53f1ac3fbd4638249e8812fa61547c421849546d Mon Sep 17 00:00:00 2001 From: mattslaney Date: Wed, 26 Jul 2023 15:46:06 +0100 Subject: [PATCH] Create context menus on install --- pd-notifier/service_worker.js | 42 +++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/pd-notifier/service_worker.js b/pd-notifier/service_worker.js index bcbbd2f..8937eb1 100644 --- a/pd-notifier/service_worker.js +++ b/pd-notifier/service_worker.js @@ -47,6 +47,27 @@ chrome.runtime.onInstalled.addListener(function (details) { }); } }); + + // Add option to trigger a test notification popup. + chrome.contextMenus.create({ + title: "Show test notification", + id: "pd_test_notification", + contexts: ["action"], + visible: true + }); + + chrome.contextMenus.onClicked.addListener(function (info) { + if (info.menuItemId === "pd_test_notification") { + _pdNotifier.triggerNotification({ + 'id': 'test', + 'summary': 'Test Notification', + 'service': { + 'summary': 'Test Service' + }, + 'urgency': 'high' + }); + } + }); }); // Add event handlers for button/notification clicks, and delegate to the currently active notifier object. @@ -62,25 +83,4 @@ chrome.notifications.onClicked.addListener(function (notificationId) { // Add event handler for the toolbar icon click. chrome.action.onClicked.addListener(function (tab) { getNotifier().openDashboard(); -}); - -// Add option to trigger a test notification popup. -chrome.contextMenus.create({ - title: "Show test notification", - id: "pd_test_notification", - contexts: ["action"], - visible: true -}); - -chrome.contextMenus.onClicked.addListener(function (info) { - if (info.menuItemId === "pd_test_notification") { - _pdNotifier.triggerNotification({ - 'id': 'test', - 'summary': 'Test Notification', - 'service': { - 'summary': 'Test Service' - }, - 'urgency': 'high' - }); - } }); \ No newline at end of file