[FIX] mail: only prevent odoobot new messages during onboarding

Before this commit, new messages from odoobot were never opening
a chat window automatically.

This is desirable only during the onboarding process of the user,
when first logging-in, as to not bully the new user. It is not
intended to prevent all new messages from odoobot.

This commit fixes the issue by only preventing auto-opening of
chat window of odoobot for the 1st step of the onboarding process.

closes odoo/odoo#132689

Signed-off-by: Louis Wicket (wil) <wil@odoo.com>
This commit is contained in:
Alexandre Kühn
2023-08-23 18:55:17 +02:00
parent 6faafdefa3
commit fec00da16e
5 changed files with 16 additions and 7 deletions
@@ -98,6 +98,7 @@ export class Messaging {
});
this.store.hasLinkPreviewFeature = data.hasLinkPreviewFeature;
this.store.initBusId = data.initBusId;
this.store.odoobotOnboarding = data.odoobotOnboarding;
this.isReady.resolve(data);
this.store.isMessagingReady = true;
}
@@ -90,6 +90,7 @@ export class Store {
/** @type {import("@mail/core/common/persona_model").Persona} */
odoobot = null;
odoobotOnboarding;
/** @type {Object.<number, import("@mail/core/common/persona_model").Persona>} */
personas = {};
@@ -48,13 +48,15 @@ export class DiscussCoreWeb {
this.env.bus.addEventListener(
"discuss.channel/new_message",
({ detail: { channel, message } }) => {
if (
!this.ui.isSmall &&
channel.correspondent !== this.store.odoobot &&
!message.isSelfAuthored
) {
this.chatWindowService.insert({ thread: channel });
if (this.ui.isSmall || message.isSelfAuthored) {
return;
}
if (channel.correspondent === this.store.odoobot && this.store.odoobotOnboarding) {
// this cancels odoobot onboarding auto-opening of chat window
this.store.odoobotOnboarding = false;
return;
}
this.chatWindowService.insert({ thread: channel });
}
);
this.busService.subscribe("mail.record/insert", (payload) => {