From 5d0b9285449257e6878091ddead022cefda73bce Mon Sep 17 00:00:00 2001 From: Nicolas Lempereur Date: Mon, 19 Dec 2016 09:49:33 +0100 Subject: [PATCH] [IMP] mail: don't clear undelivered chatter message When a message is sent on the chatter and the call fails (for example because of an internet connection failure), the message was still cleared so the content was lost. This change keep the same behavior for chat window and discuss, but change the behavior in a chatter so the message is only cleared if the rpc has passed. closes #14759 opw-696971 --- addons/mail/static/src/js/chatter.js | 10 +++++++--- addons/mail/static/src/js/composer.js | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index c55c04d71c4..84e6d92414c 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -91,6 +91,10 @@ var ChatterComposer = composer.BasicComposer.extend({ return def; }, + clear_composer_on_send: function() { + /* chatter don't clear message on sent but after successful sent */ + }, + /** * Send the message on SHIFT+ENTER, but go to new line on ENTER */ @@ -382,13 +386,13 @@ var Chatter = form_common.AbstractField.extend({ chat_manager .post_message(message, options) .then(function () { - self.close_composer(); + self.close_composer(true); if (message.partner_ids.length) { self.refresh_followers(); // refresh followers' list } }) .fail(function () { - // todo: display notification + self.do_notify(_t('Sending Error'), _t('Your message has not been sent.')); }); }, @@ -538,7 +542,7 @@ var Chatter = form_common.AbstractField.extend({ close_composer: function (force) { if (this.composer && (this.composer.is_empty() || force)) { this.composer.do_hide(); - this.composer.$input.val(''); + this.composer.clear_composer(); this.mute_new_message_button(false); } }, diff --git a/addons/mail/static/src/js/composer.js b/addons/mail/static/src/js/composer.js index 6560e76fb13..a3b86e54c8c 100644 --- a/addons/mail/static/src/js/composer.js +++ b/addons/mail/static/src/js/composer.js @@ -493,16 +493,22 @@ var BasicComposer = Widget.extend({ var self = this; this.preprocess_message().then(function (message) { self.trigger('post_message', message); - - // Empty input, selected partners and attachments - self.$input.val(''); - self.mention_manager.reset_selections(); - self.set('attachment_ids', []); - + self.clear_composer_on_send(); self.$input.focus(); }); }, + clear_composer: function() { + // Empty input, selected partners and attachments + this.$input.val(''); + this.mention_manager.reset_selections(); + this.set('attachment_ids', []); + }, + + clear_composer_on_send: function() { + this.clear_composer(); + }, + // Events on_click_add_attachment: function () { this.$('input.o_form_input_file').click();