[FIX] mail: do not auto-open chat window with odoobot on login
closes odoo/odoo#117978 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
@@ -114,6 +114,9 @@ export class MessagingMenu extends Component {
|
||||
threads = threads.filter(({ type }) => this.tabToThreadType(tab).includes(type));
|
||||
}
|
||||
threads.sort((a, b) => {
|
||||
if (a.correspondent === this.store.odoobot) {
|
||||
return 1;
|
||||
}
|
||||
if (!a.mostRecentNonTransientMessage?.datetime) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,9 @@ patch(Messaging.prototype, "mail/web", {
|
||||
async _handleNotificationNewMessage(notif) {
|
||||
await this._super(notif);
|
||||
const channel = this.store.threads[createLocalId("mail.channel", notif.payload.id)];
|
||||
this.chatWindowService.insert({ thread: channel });
|
||||
if (channel.correspondent !== this.store.odoobot) {
|
||||
this.chatWindowService.insert({ thread: channel });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -651,6 +651,29 @@ QUnit.test("chat window should open when receiving a new DM", async (assert) =>
|
||||
assert.containsOnce($, ".o-mail-ChatWindow");
|
||||
});
|
||||
|
||||
QUnit.test("chat window should not open when receiving a new DM from odoobot", async (assert) => {
|
||||
const pyEnv = await startServer();
|
||||
const userId = pyEnv["res.users"].create({ partner_id: pyEnv.odoobotId });
|
||||
pyEnv["mail.channel"].create({
|
||||
channel_member_ids: [
|
||||
[0, 0, { is_pinned: false, partner_id: pyEnv.currentPartnerId }],
|
||||
[0, 0, { partner_id: pyEnv.odoobotId }],
|
||||
],
|
||||
channel_type: "chat",
|
||||
uuid: "channel-uuid",
|
||||
});
|
||||
const { env } = await start();
|
||||
// simulate receiving new message from odoobot
|
||||
await afterNextRender(() =>
|
||||
env.services.rpc("/mail/chat_post", {
|
||||
context: { mockedUserId: userId },
|
||||
message_content: "new message",
|
||||
uuid: "channel-uuid",
|
||||
})
|
||||
);
|
||||
assert.containsNone($, ".o-mail-ChatWindow");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"chat window should scroll to the newly posted message just after posting it",
|
||||
async (assert) => {
|
||||
|
||||
Reference in New Issue
Block a user