Skip to content

Commit

Permalink
[MIG] web_notify: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
baimont committed Feb 17, 2023
1 parent 5cac78f commit 4a702c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion web_notify/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
25 changes: 12 additions & 13 deletions web_notify/static/src/js/services/notification_services.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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();
});

},
};

Expand Down

0 comments on commit 4a702c5

Please sign in to comment.