From 1a338fb9e5de625d6cb7d7866fcfc96ccba6eee7 Mon Sep 17 00:00:00 2001 From: SapuSeven Date: Sun, 28 Mar 2021 23:33:10 +0200 Subject: [PATCH] Add advanced configuration menu for notifications --- plugins/notifications/menu.js | 13 +++++++++++++ plugins/notifications/utils.js | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 plugins/notifications/menu.js create mode 100644 plugins/notifications/utils.js diff --git a/plugins/notifications/menu.js b/plugins/notifications/menu.js new file mode 100644 index 00000000..83a7e4f6 --- /dev/null +++ b/plugins/notifications/menu.js @@ -0,0 +1,13 @@ +const {urgencyLevels, setUrgency} = require("./utils"); + +module.exports = (win, options) => [ + { + label: "Notification Priority", + submenu: urgencyLevels.map(level => ({ + label: level.name, + type: "radio", + checked: options.urgency === level.value, + click: () => setUrgency(options, level.value) + })), + }, +]; diff --git a/plugins/notifications/utils.js b/plugins/notifications/utils.js new file mode 100644 index 00000000..f80dd342 --- /dev/null +++ b/plugins/notifications/utils.js @@ -0,0 +1,11 @@ +const {setOptions} = require("../../config/plugins"); + +module.exports.urgencyLevels = [ + {name: "Low", value: "low"}, + {name: "Normal", value: "normal"}, + {name: "High", value: "critical"}, +]; +module.exports.setUrgency = (options, level) => { + options.urgency = level + setOptions("notifications", options) +};