[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#71258 X-original-commit: 6e84914a3691735e9c97084cc8d55788babd2ad9 Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
+42
-15
@@ -2228,7 +2228,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({
|
||||
@@ -2251,16 +2251,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({
|
||||
@@ -2289,10 +2280,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) {
|
||||
@@ -2487,6 +2474,46 @@ QUnit.test('chat window should open when receiving a new DM', async function (as
|
||||
);
|
||||
});
|
||||
|
||||
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"
|
||||
);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+2
-2
@@ -260,8 +260,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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user