diff options
| author | Dhruv Patel <dhp@odoo.com> | 2021-05-12 11:17:51 +0000 |
|---|---|---|
| committer | Dhruv Patel <dhp@odoo.com> | 2021-05-21 04:38:56 +0000 |
| commit | cf3bf892c9833cd38a8269c8948d845dd3652403 (patch) | |
| tree | 99860544e1bf8f8511edb1b4faf977bdb2fd135d /addons | |
| parent | f3c5dd794e4de71187fd7532c39595b2297eb93d (diff) | |
[FIX] mail: chat window should remain folded on new message
If the chat window was initially folded and when a new message is received
the chat window automatically unfolds. it is annoying having a window that
pops up each time a new message is coming while having folded it once.
So, It should remain folded when a new message is received if the chat
window is already folded.
Task : 2522141
closes odoo/odoo#70737
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons')
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); } } |
