summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2019-12-06 13:33:13 +0000
committerAlexandre Kühn <aku@odoo.com>2019-12-09 09:26:25 +0000
commit42de9e129f0832c57ad3845bcbfc9c5b3b1bb301 (patch)
tree7940324c0970b820ebf035d2bebd5aa6b8efeb7e /addons
parent4efe0e3b161a46d4d0528df91a825c55cc96fb65 (diff)
[REV] mail: prevent message loss during connection issue
This reverts commit e5479fcfdb76bdbf9301fb140d873483bafdb9e4. This commit prevented an issue of losing messages on post in case of connectivity loss. The implementation consists of keeping the content in the composer until the server acknowledges handling the message. However, this solution introduces significant issues. For instance, sending messages in quick succession will likely loose or duplicate some content, based on how fast/slow the RPC `message_post` is resolved. Plus, there was an issue on mobile because the input focus was lost during the RPC. As a consequence, the virtual keyboard flickered. The intent was to fix a rare issue, and since the problems of this solution clearly outweigh the gain, we decided to revert. closes odoo/odoo#41544 X-original-commit: 36b2e99e08bfc6d92a821d0346e783695580abf9 Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/static/src/js/composers/basic_composer.js7
-rw-r--r--addons/mail/static/src/js/discuss.js4
-rw-r--r--addons/mail/static/src/js/thread_windows/abstract_thread_window.js4
-rw-r--r--addons/mail/static/tests/discuss_tests.js51
4 files changed, 5 insertions, 61 deletions
diff --git a/addons/mail/static/src/js/composers/basic_composer.js b/addons/mail/static/src/js/composers/basic_composer.js
index bfd97028a2d..c2ca59ffa65 100644
--- a/addons/mail/static/src/js/composers/basic_composer.js
+++ b/addons/mail/static/src/js/composers/basic_composer.js
@@ -523,10 +523,9 @@ var BasicComposer = Widget.extend({
clearTimeout(this._cannedTimeout);
var self = this;
this._preprocessMessage().then(function (message) {
- self.trigger('post_message', message, function() {
- self._clearComposerOnSend();
- self.$input.focus();
- });
+ self.trigger('post_message', message);
+ self._clearComposerOnSend();
+ self.$input.focus();
});
},
/**
diff --git a/addons/mail/static/src/js/discuss.js b/addons/mail/static/src/js/discuss.js
index 0f2b7feff26..168e74cac4a 100644
--- a/addons/mail/static/src/js/discuss.js
+++ b/addons/mail/static/src/js/discuss.js
@@ -1490,9 +1490,8 @@ var Discuss = AbstractAction.extend({
/**
* @private
* @param {Object} messageData
- * @param {Function} callback
*/
- _onPostMessage: function (messageData, callback) {
+ _onPostMessage: function (messageData) {
var self = this;
var options = {};
if (this._selectedMessage) {
@@ -1513,7 +1512,6 @@ var Discuss = AbstractAction.extend({
} else {
self._threadWidget.scrollToBottom();
}
- callback();
});
},
/**
diff --git a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
index 27cb97e1f65..7ec1c214ef1 100644
--- a/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
+++ b/addons/mail/static/src/js/thread_windows/abstract_thread_window.js
@@ -372,9 +372,8 @@ var AbstractThreadWindow = Widget.extend({
*
* @private
* @param {Object} messageData
- * @param {Function} callback
*/
- _postMessage: function (messageData, callback) {
+ _postMessage: function (messageData) {
var self = this;
if (!this.hasThread()) {
return;
@@ -382,7 +381,6 @@ var AbstractThreadWindow = Widget.extend({
this._thread.postMessage(messageData)
.then(function () {
self._threadWidget.scrollToBottom();
- callback && callback();
});
},
/**
diff --git a/addons/mail/static/tests/discuss_tests.js b/addons/mail/static/tests/discuss_tests.js
index bc31013ce52..8e8b663e83f 100644
--- a/addons/mail/static/tests/discuss_tests.js
+++ b/addons/mail/static/tests/discuss_tests.js
@@ -1733,57 +1733,6 @@ QUnit.test('receive channel message notification then delayed needaction notific
discuss.destroy();
});
-QUnit.test('input not cleared on unresolved message_post rpc', async function (assert) {
- assert.expect(2);
- // Promise to simulate late server response on message post
- var messagePostPromise = testUtils.makeTestPromise();
-
- this.data.initMessaging = {
- channel_slots: {
- channel_channel: [{
- id: 1,
- channel_type: "channel",
- name: "general",
- }],
- },
- };
-
- var discuss = await createDiscuss({
- id: 1,
- context: {},
- params: {},
- data: this.data,
- services: this.services,
- mockRPC: function (route, args) {
- if (args.method === 'message_post') {
- return messagePostPromise;
- }
- return this._super.apply(this, arguments);
- },
- });
-
- // Click on channel 'general'
- var $general = discuss.$('.o_mail_discuss_sidebar').find('.o_mail_discuss_item[data-thread-id=1]');
- await testUtils.dom.click($general);
-
- // Type message
- var $input = discuss.$('textarea.o_composer_text_field').first();
- $input.focus();
- $input.val('test message');
-
- // Send message
- await testUtils.fields.triggerKeydown($input, 'enter');
- assert.strictEqual($input.val(), 'test message', "composer should not be cleared on send without server response");
-
- // Simulate server response
- messagePostPromise.resolve();
-
- await testUtils.nextTick();
- assert.strictEqual($input.val(), '', "composer should be cleared on send after server response");
-
- discuss.destroy();
-});
-
QUnit.test('messages marked as read move to "History" mailbox', async function (assert) {
assert.expect(3);