/** @odoo-module **/ import { browser } from "@web/core/browser/browser"; import { registry } from "@web/core/registry"; /** * License Bus Service * Listens for license status updates from the server and reloads the page when needed. */ export const licenseBusService = { dependencies: ["bus_service", "notification"], start(env, { bus_service, notification }) { // Subscribe to license status updates bus_service.subscribe("license/status_update", (payload) => { console.log("License status update received:", payload); const { module_name, action, state, message, requires_reload } = payload; // Show notification to user if (action === "suspend" || action === "revoke") { notification.add(message || `License for ${module_name} has been ${state}`, { title: "License Status Changed", type: "danger", sticky: true, }); // Reload page after 3 seconds to apply changes if (requires_reload) { setTimeout(() => { browser.location.reload(); }, 3000); } } else if (action === "activate") { notification.add(message || `License for ${module_name} has been activated`, { title: "License Activated", type: "success", sticky: false, }); } }); }, }; registry.category("services").add("license_bus", licenseBusService);