[FIX] im_livechat,mail: don't automatically detach chat channels
This reverts commit a8239cd as the navbar dropdown recently introduced now
offers a quick access to channels without coming back in the Discuss App.
Moreover, this commit emphasizes the notifications navbar icon when there are
unread messages (or at least, it mutes it when there isn't).
This commit is contained in:
@@ -177,8 +177,6 @@ class ImLivechatChannel(models.Model):
|
||||
'public': 'public',
|
||||
'email_send': False,
|
||||
})
|
||||
# minimize channel on operator's side
|
||||
mail_channel._minimize([operator_partner_id])
|
||||
return mail_channel.sudo().with_context(im_livechat_operator_partner_id=operator_partner_id).channel_info()[0]
|
||||
|
||||
@api.model
|
||||
|
||||
@@ -152,16 +152,6 @@ class Channel(models.Model):
|
||||
for mail_channel in self:
|
||||
mail_channel.write({'channel_partner_ids': [(4, pid) for pid in mail_channel.mapped('group_ids').mapped('users').mapped('partner_id').ids]})
|
||||
|
||||
@api.multi
|
||||
def _minimize(self, partner_ids):
|
||||
self.ensure_one()
|
||||
domain = [('channel_id', '=', self.id), ('partner_id', 'in', tuple(partner_ids))]
|
||||
channel_partners = self.env['mail.channel.partner'].search(domain)
|
||||
channel_partners.write({
|
||||
'is_minimized': True,
|
||||
'fold_state': 'open',
|
||||
})
|
||||
|
||||
@api.multi
|
||||
def action_follow(self):
|
||||
self.ensure_one()
|
||||
@@ -363,8 +353,8 @@ class Channel(models.Model):
|
||||
:rtype : dict
|
||||
"""
|
||||
if partners_to:
|
||||
partners = partners_to + [self.env.user.partner_id.id]
|
||||
# determine type according to the number of partners in the channel
|
||||
partners_to.append(self.env.user.partner_id.id)
|
||||
# determine type according to the number of partner in the channel
|
||||
self.env.cr.execute("""
|
||||
SELECT P.channel_id as channel_id
|
||||
FROM mail_channel C, mail_channel_partner P
|
||||
@@ -374,7 +364,7 @@ class Channel(models.Model):
|
||||
AND channel_type LIKE 'chat'
|
||||
GROUP BY P.channel_id
|
||||
HAVING COUNT(P.partner_id) = %s
|
||||
""", (tuple(partners), len(partners),))
|
||||
""", (tuple(partners_to), len(partners_to),))
|
||||
result = self.env.cr.dictfetchall()
|
||||
if result:
|
||||
# get the existing channel between the given partners
|
||||
@@ -385,16 +375,14 @@ class Channel(models.Model):
|
||||
else:
|
||||
# create a new one
|
||||
channel = self.create({
|
||||
'channel_partner_ids': [(4, partner_id) for partner_id in partners],
|
||||
'channel_partner_ids': [(4, partner_id) for partner_id in partners_to],
|
||||
'public': 'private',
|
||||
'channel_type': 'chat',
|
||||
'email_send': False,
|
||||
'name': ', '.join(self.env['res.partner'].sudo().browse(partners).mapped('name')),
|
||||
'name': ', '.join(self.env['res.partner'].sudo().browse(partners_to).mapped('name')),
|
||||
})
|
||||
# minimize the DM on other partners' side
|
||||
channel._minimize(partners_to)
|
||||
# broadcast the channel header
|
||||
channel._broadcast(partners)
|
||||
# broadcast the channel header to the other partner (not me)
|
||||
channel._broadcast(partners_to)
|
||||
return channel.channel_info()[0]
|
||||
return False
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ var MessagingMenu = Widget.extend({
|
||||
update_counter: function () {
|
||||
var counter = chat_manager.get_needaction_counter() + chat_manager.get_chat_unread_counter();
|
||||
this.$('.o_notification_counter').text(counter);
|
||||
this.$el.toggleClass('o_no_notification', !counter);
|
||||
if (this.is_open()) {
|
||||
this.render_channels_preview();
|
||||
}
|
||||
|
||||
@@ -262,11 +262,23 @@
|
||||
|
||||
// Navbar icon and dropdown (FIXME: move to systray.less)
|
||||
.o_mail_navbar_item {
|
||||
> a {
|
||||
opacity: 1;
|
||||
> i {
|
||||
font-size: larger;
|
||||
}
|
||||
}
|
||||
&.o_no_notification > a {
|
||||
opacity: 0.5;
|
||||
.o_notification_counter {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.open .o_mail_navbar_dropdown {
|
||||
.o-flex-display();
|
||||
.o-flex-flow(column, nowrap);
|
||||
}
|
||||
|
||||
.o_mail_navbar_dropdown {
|
||||
width: 350px;
|
||||
padding: 0;
|
||||
|
||||
Reference in New Issue
Block a user