From 019fcae90ba8302b01554f746b98962b705c6a88 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Tue, 3 May 2016 09:06:06 +0200 Subject: [PATCH] [FIX] mail: messages sent as reply to previously selected message In Discuss, if a message was selected as message to reply to, it wasn't reset when switching to another channel. So if the user sent a message in that other channel, the message was sent as reply to the previously selected message. This rev. ensures to always unselect messages when switching between channels. Closes #11879 --- addons/mail/static/src/js/client_action.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 8b10d5eb282..0e27eb10fbb 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -272,12 +272,13 @@ var ChatAction = Widget.extend(ControlPanelMixin, { }, unselect_message: function() { - if (this.channel.type !== 'static' && !this.channel.mass_mailing) { - this.basic_composer.toggle(true); - this.basic_composer.focus(); + this.basic_composer.toggle(this.channel.type !== 'static' && !this.channel.mass_mailing); + this.extended_composer.toggle(this.channel.type !== 'static' && this.channel.mass_mailing); + if (!config.device.touch) { + var composer = this.channel.mass_mailing ? this.extended_composer : this.basic_composer; + composer.focus(); } this.$el.removeClass('o_mail_selection_mode'); - this.extended_composer.toggle(this.channel.mass_mailing); this.thread.unselect(); this.selected_message = null; }, @@ -413,10 +414,6 @@ var ChatAction = Widget.extend(ControlPanelMixin, { .find('.o_mail_chat_button_unstar_all') .toggle(channel.id === "channel_starred"); - self.basic_composer.toggle(channel.type !== 'static' && !channel.mass_mailing); - self.extended_composer.toggle(channel.type !== 'static' && channel.mass_mailing); - self.$el.removeClass('o_mail_selection_mode'); - self.$('.o_mail_chat_channel_item') .removeClass('o_active') .filter('[data-channel-id=' + channel.id + ']') @@ -432,14 +429,14 @@ var ChatAction = Widget.extend(ControlPanelMixin, { // Update control panel before focusing the composer, otherwise focus is on the searchview self.update_cp(); - if (!config.device.touch) { - var composer = channel.mass_mailing ? self.extended_composer : self.basic_composer; - composer.focus(); - } if (config.device.size_class === config.device.SIZES.XS) { self.$('.o_mail_chat_sidebar').hide(); } + // Display and focus the adequate composer, and unselect possibly selected message + // to prevent sending messages as reply to that message + self.unselect_message(); + self.action_manager.do_push_state({ action: self.action.id, active_id: self.channel.id,