summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/components/thread_view
diff options
context:
space:
mode:
authorSébastien Theys <seb@odoo.com>2020-09-23 10:50:45 +0000
committerSébastien Theys <seb@odoo.com>2020-09-23 17:08:02 +0000
commitdb208c76f7de734fdcaf977412137bd9ea0d82ac (patch)
tree7f03fbbabef9abfc043e91c69ed4f640c0d90cae /addons/mail/static/src/components/thread_view
parentb9d4ccfc8db1f3425b8ee0e8d6311ebaac0f26b2 (diff)
[FIX] mail: prevent unnecessary fold state RPC
When the pending value is the same as the current server value, the pending value should be ignored and no RPC should be done. In particular this prevents a non-main tab from calling the RPC when receiving a bus notification that would lead to closing a chat window, which in turn used to call the close RPC again before this commit. This led to inconsistencies especially on the main tab, if the chat window was requested to be open again after the initial close, but before the "secondary" close, it would end up closing instead of opening. The current commit reduces the issue and prevents as many unnecessary RPC as there are tabs open, which is a good improvement. But it does not negate it completely. Indeed, when quickly closing then opening the same chat window, it might still happen for network reasons that the RPC or the corresponding bus notifications are received in the wrong order. This is less frequent both functionally (to click so fast) and technically (to have the network that slow) at the same time, so it is considering acceptable / out of scope. The opportunity is taken to clean up the code by removing unnecessary fields and making use of compute and flux specific RPC instead of `_updateAfter`. task-2273658 task-2329521 closes odoo/odoo#58367 X-original-commit: cbb1d855c7af5f78819db3cd476dbe0f985bc214 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com> Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Diffstat (limited to 'addons/mail/static/src/components/thread_view')
-rw-r--r--addons/mail/static/src/components/thread_view/thread_view_tests.js56
1 files changed, 26 insertions, 30 deletions
diff --git a/addons/mail/static/src/components/thread_view/thread_view_tests.js b/addons/mail/static/src/components/thread_view/thread_view_tests.js
index d93f911e04a..4aa2d195686 100644
--- a/addons/mail/static/src/components/thread_view/thread_view_tests.js
+++ b/addons/mail/static/src/components/thread_view/thread_view_tests.js
@@ -242,6 +242,21 @@ QUnit.test('message list asc order', async function (assert) {
QUnit.test('mark channel as fetched when a new message is loaded and as seen when focusing composer [REQUIRE FOCUS]', async function (assert) {
assert.expect(8);
+ this.data['res.partner'].records.push({
+ email: "fred@example.com",
+ id: 10,
+ name: "Fred",
+ });
+ this.data['res.users'].records.push({
+ id: 10,
+ partner_id: 10,
+ });
+ this.data['mail.channel'].records.push({
+ channel_type: 'chat',
+ id: 100,
+ is_pinned: true,
+ members: [this.data.currentPartnerId, 10],
+ });
await this.start({
mockRPC(route, args) {
if (args.method === 'channel_fetched') {
@@ -272,44 +287,25 @@ QUnit.test('mark channel as fetched when a new message is loaded and as seen whe
return this._super(...arguments);
}
});
- const thread = this.env.models['mail.thread'].create({
+ const thread = this.env.models['mail.thread'].findFromIdentifyingData({
id: 100,
- isServerPinned: true, // just to avoid joinChannel to be called
- members: [['insert', [
- {
- email: "john@example.com",
- id: this.env.messaging.currentPartner.id,
- name: "John",
- },
- {
- email: "fred@example.com",
- id: 10,
- name: "Fred",
- },
- ]]],
model: 'mail.channel',
- serverMessageUnreadCounter: 1, // seen would not be called if not > 0
});
-
const threadViewer = this.env.models['mail.thread_viewer'].create({
hasThreadView: true,
thread: [['link', thread]],
});
await this.createThreadViewComponent(threadViewer.threadView, { hasComposer: true });
- const notifications = [
- [['myDB', 'mail.channel', 100], {
- channelId: 100,
- id: 1,
- body: "<p>fdsfsd</p>",
- author_id: [10, "Fred"],
- model: "mail.channel",
- channel_ids: [100],
- }]
- ];
-
- await afterNextRender(() =>
- this.widget.call('bus_service', 'trigger', 'notification', notifications)
- );
+ await afterNextRender(async () => this.env.services.rpc({
+ route: '/mail/chat_post',
+ params: {
+ context: {
+ mockedUserId: 10,
+ },
+ uuid: thread.uuid,
+ message_content: "new message",
+ },
+ }));
assert.verifySteps(
['rpc:channel_fetch'],
"Channel should have been fetched but not seen yet"