From c2dfea5cc9a7f860d513809cb82cfe26e639de7c Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Thu, 19 Nov 2015 14:57:33 +0100 Subject: [PATCH] [FIX] mail: correctly load livechat channels The livechat channels returned by the chat_manager's initial RPC were ignored. Livechat channels thus weren't persistent in the client action. This rev. cleans the returned object 'channel_slots' so that it only contains arrays of channels. The additional mapping and partners array were useless as the information they contained was directly stored in the DM channels. We now simply iterate on each array returned and add each channel it contains, including livechat channels. --- addons/mail/models/mail_channel.py | 6 ------ addons/mail/static/src/js/chat_manager.js | 6 +++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/addons/mail/models/mail_channel.py b/addons/mail/models/mail_channel.py index ee4ed01b324..90761db60cc 100644 --- a/addons/mail/models/mail_channel.py +++ b/addons/mail/models/mail_channel.py @@ -467,12 +467,6 @@ class Channel(models.Model): direct_message_channels = self.search([('channel_type', '=', 'chat'), ('id', 'in', pinned_channels.ids)]) values['channel_direct_message'] = direct_message_channels.channel_info() - # get the partner of the pinned 'direct message' channels with mapping partner/channel - direct_channel_partner = direct_message_channels.mapped('channel_last_seen_partner_ids').filtered(lambda cp: cp.partner_id.id != my_partner_id) - values['mapping'] = dict((item.partner_id.id, item.channel_id.id) for item in direct_channel_partner) - # partners of the 'direct message' channels - values['partners'] = direct_message_channels.mapped('channel_partner_ids').filtered(lambda partner: partner.id != my_partner_id).read(['id', 'name', 'im_status']) - # get the private group values['channel_private_group'] = self.search([('channel_type', '=', 'channel'), ('public', '=', 'private'), ('channel_partner_ids', 'in', [my_partner_id])]).channel_info() return values diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 7860667814b..d16683d3647 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -589,9 +589,9 @@ function init () { }); var load_channels = session.rpc('/mail/client_action').then(function (result) { - _.each(result.channel_slots.channel_channel, add_channel); - _.each(result.channel_slots.channel_private_group, add_channel); - _.each(result.channel_slots.channel_direct_message, add_channel); + _.each(result.channel_slots, function (channels) { + _.each(channels, add_channel); + }); needaction_counter = result.needaction_inbox_counter; });