Commit c28b3cdb authored by Dave Vandyke's avatar Dave Vandyke 🐈

Refs #27 - Correct notification configure button logic

parent 57ba9104
Pipeline #73692284 passed with stages
in 7 minutes and 47 seconds
......@@ -94,9 +94,13 @@ function getNotificationButtons({type: notificationType, links}, message)
});
}
// We allow the user to disable non-essential notifications, and we add a
// button to those notifications to make that easier to do.
let addConfigureButton = isOptional(notificationType);
// Chrome only allows two notification buttons so we need to fall back
// to a single button to open all links if there are more than two.
let maxButtons = (notificationType == "critical") ? 2 : 1;
let maxButtons = addConfigureButton ? 1 : 2;
if (buttons.length > maxButtons)
{
buttons = [
......@@ -106,7 +110,7 @@ function getNotificationButtons({type: notificationType, links}, message)
}
];
}
if (!["critical", "relentless"].includes(notificationType))
if (addConfigureButton)
{
buttons.push({
type: "configure",
......@@ -344,6 +348,19 @@ exports.shouldDisplay = (method, notificationType) =>
return methods.includes(method);
};
let isOptional =
/**
* If the given notification type is of vital importance return false,
* true otherwise.
*
* @param {string} notificationType
* @return {boolean}
*/
exports.isOptional = notificationType =>
{
return !["critical", "relentless"].includes(notificationType);
};
let notificationClicked =
/**
* Tidies up after the currently active notification was clicked.
......
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