Skip to content

Commit

Permalink
Create context menus on install
Browse files Browse the repository at this point in the history
  • Loading branch information
mattslaney committed Jul 26, 2023
1 parent d2a44d0 commit 53f1ac3
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions pd-notifier/service_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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'
});
}
});

0 comments on commit 53f1ac3

Please sign in to comment.