From 4a702c587254cbdd7f7562fb244f12bfa6a0ecde Mon Sep 17 00:00:00 2001 From: Benoit Aimont Date: Thu, 16 Feb 2023 15:58:15 +0100 Subject: [PATCH] [MIG] web_notify: Migration to 16.0 --- web_notify/__manifest__.py | 2 +- .../js/services/notification_services.esm.js | 25 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/web_notify/__manifest__.py b/web_notify/__manifest__.py index 87b21d879b4b..4ae53d1b13a4 100644 --- a/web_notify/__manifest__.py +++ b/web_notify/__manifest__.py @@ -6,7 +6,7 @@ "name": "Web Notify", "summary": """ Send notification messages to user""", - "version": "15.0.1.0.0", + "version": "16.0.1.0.0", "license": "AGPL-3", "author": "ACSONE SA/NV," "AdaptiveCity," "Odoo Community Association (OCA)", "development_status": "Production/Stable", diff --git a/web_notify/static/src/js/services/notification_services.esm.js b/web_notify/static/src/js/services/notification_services.esm.js index 65a0d327644f..7a9fc90c1c22 100644 --- a/web_notify/static/src/js/services/notification_services.esm.js +++ b/web_notify/static/src/js/services/notification_services.esm.js @@ -3,14 +3,23 @@ import {browser} from "@web/core/browser/browser"; import {registry} from "@web/core/registry"; export const webNotificationService = { - dependencies: ["notification"], + dependencies: ["bus_service", "notification"], - start(env, {notification}) { + start(env, {bus_service, notification}) { let webNotifTimeouts = {}; /** * Displays the web notification on user's screen */ + bus_service.addEventListener('notification', ({ detail: notifications }) => { + for (const { payload, type } of notifications) { + if (type === "web.notify") { + displaywebNotification(payload); + } + } + }); + bus_service.start(); + function displaywebNotification(notifications) { Object.values(webNotifTimeouts).forEach((notif) => browser.clearTimeout(notif) @@ -28,17 +37,7 @@ export const webNotificationService = { }); }); } - env.bus.on("WEB_CLIENT_READY", null, async () => { - const legacyEnv = owl.Component.env; - legacyEnv.services.bus_service.onNotification(this, (notifications) => { - for (const {payload, type} of notifications) { - if (type === "web.notify") { - displaywebNotification(payload); - } - } - }); - legacyEnv.services.bus_service.startPolling(); - }); + }, };