[IMP] bus, *: remove obsolete web_client_ready when using bus

*: calendar, iap_mail.

Now that the bus service is a wowl service, we don't need to wait for
the webclient to be ready before using it. Indeed, the services now
have the bus service as a dependency which means it will always be ready
in time. This also showed that the rpc service was missing as a bus service
dependency. It has been added.

Some part of the code were also checking if the bus service was in
`env.services`. Those calls have been removed as well since we now
have the guarantee that it is.

closes odoo/odoo#96002

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
tsm-odoo
2022-07-14 16:42:19 +02:00
parent 391aa05284
commit 27b472e5ed
6 changed files with 21 additions and 31 deletions
@@ -11,10 +11,8 @@ export const assetsWatchdogService = {
let isNotificationDisplayed = false;
let bundleNotifTimerID = null;
env.bus.on("WEB_CLIENT_READY", null, async () => {
bus_service.onNotification(this, onNotification);
bus_service.startPolling();
});
bus_service.onNotification(this, onNotification);
bus_service.startPolling();
/**
* Displays one notification on user's screen when assets have changed
@@ -113,7 +113,7 @@ export class BusService extends CrossTab {
}
export const busService = {
dependencies: ['notification'],
dependencies: ['notification', 'rpc'],
start(env, services) {
return new BusService(env, services);
},
@@ -12,16 +12,14 @@ export const calendarNotificationService = {
let nextCalendarNotifTimeout = null;
const displayedNotifications = new Set();
env.bus.on("WEB_CLIENT_READY", null, async () => {
bus_service.onNotification(this, (notifications) => {
for (const { payload, type } of notifications) {
if (type === "calendar.alarm") {
displayCalendarNotification(payload);
}
bus_service.onNotification(this, (notifications) => {
for (const { payload, type } of notifications) {
if (type === "calendar.alarm") {
displayCalendarNotification(payload);
}
});
bus_service.startPolling();
}
});
bus_service.startPolling();
/**
* Displays the Calendar notification on user's screen
@@ -7,20 +7,18 @@ export const iapNotificationService = {
dependencies: ["bus_service", "notification"],
start(env, { bus_service, notification }) {
env.bus.on("WEB_CLIENT_READY", null, async () => {
bus_service.onNotification(this, (notifications) => {
for (const { payload, type } of notifications) {
if (type === 'iap_notification') {
if (payload.error_type == 'success') {
displaySuccessIapNotification(payload);
} else if (payload.error_type == 'danger') {
displayFailureIapNotification(payload);
}
bus_service.onNotification(this, (notifications) => {
for (const { payload, type } of notifications) {
if (type === 'iap_notification') {
if (payload.error_type == 'success') {
displaySuccessIapNotification(payload);
} else if (payload.error_type == 'danger') {
displayFailureIapNotification(payload);
}
}
});
bus_service.startPolling();
}
});
bus_service.startPolling();
/**
* Displays the IAP success notification on user's screen
+1 -3
View File
@@ -18,9 +18,7 @@ registerModel({
odoo.__DEBUG__.messaging = this;
},
_willDelete() {
if (this.env.services['bus_service']) {
this.env.services['bus_service'].off('window_focus', null, this._handleGlobalWindowFocus);
}
this.env.services['bus_service'].off('window_focus', null, this._handleGlobalWindowFocus);
delete odoo.__DEBUG__.messaging;
},
},
@@ -16,10 +16,8 @@ registerModel({
identifyingFields: ['messaging'],
lifecycleHooks: {
_willDelete() {
if (this.env.services['bus_service']) {
this.env.services['bus_service'].off('notification');
this.env.services['bus_service'].stopPolling();
}
this.env.services['bus_service'].off('notification');
this.env.services['bus_service'].stopPolling();
},
},
recordMethods: {