3
0
Fork 0

Merge PR #2933 into 15.0

Signed-off-by pedrobaeza
15.0
OCA-git-bot 2024-10-09 07:31:48 +00:00
commit 4b035cd785
1 changed files with 24 additions and 20 deletions

View File

@ -10,6 +10,7 @@ export const webNotificationService = {
let webNotifTimeouts = {};
/**
* Displays the web notification on user's screen
* @param {Array} notifications
*/
function displaywebNotification(notifications) {
Object.values(webNotifTimeouts).forEach((notif) =>
@ -18,32 +19,35 @@ export const webNotificationService = {
webNotifTimeouts = {};
notifications.forEach((notif) => {
browser.setTimeout(() => {
var buttons = [];
if (notif.action) {
const params =
(notif.action.context && notif.action.context.params) || {};
buttons = [
{
name: params.button_name || env._t("Open"),
primary: true,
onClick: async () => {
await action.doAction(notif.action);
},
...(params.button_icon && {icon: params.button_icon}),
},
];
}
const notificationRemove = notification.add(Markup(notif.message), {
title: notif.title,
type: notif.type,
sticky: notif.sticky,
className: notif.className,
messageIsHtml: notif.html,
buttons:
notif.action &&
notif.action.context &&
notif.action.context.params
? [
{
name:
notif.action.context.params.button_name ||
env._t("Open"),
primary: true,
onClick: async function () {
await action.doAction(notif.action);
notificationRemove();
},
icon:
notif.action.context.params.button_icon ||
undefined,
},
]
: [],
buttons: buttons.map((button) => {
const onClick = button.onClick;
button.onClick = async () => {
await onClick();
notificationRemove();
};
return button;
}),
});
});
});