[FIX] mail: prevent sync fold state for non-channels

task-2346650

closes odoo/odoo#58801

X-original-commit: f5b6e78e77eac27af3b3812ac3818a67acaa1c85
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Sébastien Theys
2020-09-29 11:45:53 +00:00
parent 0fb77cf0d5
commit a409fbdc5a
2 changed files with 57 additions and 0 deletions
@@ -201,6 +201,56 @@ QUnit.test('click on expand from chat window should close the chat window and op
);
});
QUnit.test('[technical] opening a non-channel chat window should not call channel_fold', async function (assert) {
// channel_fold should not be called when opening non-channels in chat
// window, because there is no server sync of fold state for them.
assert.expect(3);
await this.start({
hasChatWindow: true,
async mockRPC(route, args) {
if (route.includes('channel_fold')) {
const message = "should not call channel_fold when opening a non-channel chat window";
assert.step(message);
console.error(message);
throw Error(message);
}
return this._super(...arguments);
},
});
const thread = this.env.models['mail.thread'].create({
id: 11,
model: 'mail.channel',
});
this.env.models['mail.message'].create({
id: 21,
isNeedaction: true,
originThread: [['link', thread]],
});
await this.createThreadNeedactionPreviewComponent({
threadLocalId: thread.localId,
});
assert.containsOnce(
document.body,
'.o_ThreadNeedactionPreview',
"should have a preview initially"
);
assert.containsNone(
document.body,
'.o_ChatWindow',
"should have no chat window initially"
);
await afterNextRender(() =>
document.querySelector('.o_ThreadNeedactionPreview').click()
);
assert.containsOnce(
document.body,
'.o_ChatWindow',
"should have opened the chat window on clicking on the preview"
);
});
});
});
});
@@ -616,6 +616,13 @@ function factory(dependencies) {
* @param {string} state
*/
async notifyFoldStateToServer(state) {
if (this.model !== 'mail.channel') {
// Server sync of fold state is only supported for channels.
return;
}
if (!this.uuid) {
return;
}
return this.env.models['mail.thread'].performRpcChannelFold(this.uuid, state);
}