[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
This commit is contained in:
Nicolas Lempereur
2017-01-02 17:37:42 +01:00
parent 13af401bc2
commit 5d0b928544
2 changed files with 19 additions and 9 deletions
+7 -3
View File
@@ -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);
}
},
+12 -6
View File
@@ -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();