mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
@@ -10,6 +10,7 @@ export const webNotificationService = {
|
|||||||
let webNotifTimeouts = {};
|
let webNotifTimeouts = {};
|
||||||
/**
|
/**
|
||||||
* Displays the web notification on user's screen
|
* Displays the web notification on user's screen
|
||||||
|
* @param {Array} notifications
|
||||||
*/
|
*/
|
||||||
function displaywebNotification(notifications) {
|
function displaywebNotification(notifications) {
|
||||||
Object.values(webNotifTimeouts).forEach((notif) =>
|
Object.values(webNotifTimeouts).forEach((notif) =>
|
||||||
@@ -18,32 +19,35 @@ export const webNotificationService = {
|
|||||||
webNotifTimeouts = {};
|
webNotifTimeouts = {};
|
||||||
notifications.forEach((notif) => {
|
notifications.forEach((notif) => {
|
||||||
browser.setTimeout(() => {
|
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), {
|
const notificationRemove = notification.add(Markup(notif.message), {
|
||||||
title: notif.title,
|
title: notif.title,
|
||||||
type: notif.type,
|
type: notif.type,
|
||||||
sticky: notif.sticky,
|
sticky: notif.sticky,
|
||||||
className: notif.className,
|
className: notif.className,
|
||||||
messageIsHtml: notif.html,
|
messageIsHtml: notif.html,
|
||||||
buttons:
|
buttons: buttons.map((button) => {
|
||||||
notif.action &&
|
const onClick = button.onClick;
|
||||||
notif.action.context &&
|
button.onClick = async () => {
|
||||||
notif.action.context.params
|
await onClick();
|
||||||
? [
|
notificationRemove();
|
||||||
{
|
};
|
||||||
name:
|
return button;
|
||||||
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,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
: [],
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user