summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js57
-rw-r--r--addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js4
2 files changed, 44 insertions, 17 deletions
diff --git a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
index 979280465c3..ce82f2bba77 100644
--- a/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
+++ b/addons/mail/static/src/components/chat_window_manager/chat_window_manager_tests.js
@@ -2223,7 +2223,7 @@ QUnit.test('chat window does not fetch messages if hidden', async function (asse
});
QUnit.test('new message separator is shown in a chat window of a chat on receiving new message if there is a history of conversation', async function (assert) {
- assert.expect(6);
+ assert.expect(3);
this.data['res.partner'].records.push({ id: 10, name: "Demo" });
this.data['res.users'].records.push({
@@ -2247,16 +2247,7 @@ QUnit.test('new message separator is shown in a chat window of a chat on receivi
model: 'mail.channel',
res_id: 10,
});
- await this.start({
- mockRPC(route, args) {
- if (args.method === 'channel_fold') {
- const channel_uuid = args.kwargs.uuid;
- assert.strictEqual(channel_uuid, 'channel-10-uuid', "chat window fold state should have been sent to server");
- assert.step(`rpc:channel_fold:${channel_uuid}`);
- }
- return this._super(...arguments);
- },
- });
+ await this.start();
// simulate receiving a message
await afterNextRender(async () => this.env.services.rpc({
@@ -2285,10 +2276,6 @@ QUnit.test('new message separator is shown in a chat window of a chat on receivi
'.o_MessageList_separatorNewMessages',
"should display 'new messages' separator in the conversation, from reception of new messages"
);
- assert.verifySteps(
- ['rpc:channel_fold:channel-10-uuid'],
- "fold state of chat window of chat should have been updated to server"
- );
});
QUnit.test('new message separator is not shown in a chat window of a chat on receiving new message if there is no history of conversation', async function (assert) {
@@ -2389,6 +2376,46 @@ QUnit.test('focusing a chat window of a chat should make new message separator d
);
});
+QUnit.test('chat window should remain folded when new message is received', async function (assert) {
+ assert.expect(1);
+
+ this.data['res.partner'].records.push({ id: 10, name: "Demo" });
+ this.data['res.users'].records.push({
+ id: 42,
+ name: "Foreigner user",
+ partner_id: 10,
+ });
+ this.data['mail.channel'].records = [
+ {
+ channel_type: "chat",
+ id: 10,
+ is_minimized: true,
+ is_pinned: false,
+ members: [this.data.currentPartnerId, 10],
+ state: 'folded',
+ uuid: 'channel-10-uuid',
+ },
+ ];
+
+ await this.start();
+ // simulate receiving a new message
+ await afterNextRender(async () => this.env.services.rpc({
+ route: '/mail/chat_post',
+ params: {
+ context: {
+ mockedUserId: 42,
+ },
+ message_content: "New Message 2",
+ uuid: 'channel-10-uuid',
+ },
+ }));
+ assert.hasClass(
+ document.querySelector(`.o_ChatWindow`),
+ 'o-folded',
+ "chat window should remain folded"
+ );
+});
+
});
});
});
diff --git a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
index 6f0b316d131..f1ce13bec21 100644
--- a/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
+++ b/addons/mail/static/src/models/messaging_notification_handler/messaging_notification_handler.js
@@ -265,8 +265,8 @@ function factory(dependencies) {
// on `channel` channels for performance reasons
channel.markAsFetched();
}
- // (re)open chat on receiving new message
- if (channel.channel_type !== 'channel' && !this.env.messaging.device.isMobile) {
+ // open chat on receiving new message if it was not already opened or folded
+ if (channel.channel_type !== 'channel' && !this.env.messaging.device.isMobile && !channel.chatWindow) {
this.env.messaging.chatWindowManager.openThread(channel);
}
}