diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-07-26 15:12:29 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-07-26 15:12:29 +0200 |
| commit | bfd34e14b1be97465e135d85c76b9e626a219e7a (patch) | |
| tree | 8de54ec8f504158e965ab92e21658cab539024ee /addons/mail/static/src/js/services/mail_status_manager.js | |
| parent | 26b5b446b3dab3d66b7db054ca77e7b1a811c28a (diff) | |
| parent | 40e8b67179f212551a176d72b3851671febc1fba (diff) | |
[MERGE] forward port branch saas-12.3 up to 40e8b67179f
Diffstat (limited to 'addons/mail/static/src/js/services/mail_status_manager.js')
| -rw-r--r-- | addons/mail/static/src/js/services/mail_status_manager.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/addons/mail/static/src/js/services/mail_status_manager.js b/addons/mail/static/src/js/services/mail_status_manager.js index 7891461c9af..a40299a02d5 100644 --- a/addons/mail/static/src/js/services/mail_status_manager.js +++ b/addons/mail/static/src/js/services/mail_status_manager.js @@ -54,13 +54,45 @@ MailManager.include({ updateImStatus: function (statusList) { var updatedIDs = []; var self = this; + var dmChat; + var toUpdateOutOfOfficeChatIDs = []; _.each(statusList, function (status) { if (self._imStatus[status.id] === status.im_status) { return; } + if ( + status.im_status.indexOf('leave') !== -1 || + ( + self._imStatus[status.id] && + self._imStatus[status.id].indexOf('leave') !== -1 + ) + ) { + dmChat = self.getDMChatFromPartnerID(status.id); + if (dmChat) { + toUpdateOutOfOfficeChatIDs.push(dmChat.getID()); + } + } updatedIDs.push(status.id); self._imStatus[status.id] = status.im_status; }); + if (!_.isEmpty(toUpdateOutOfOfficeChatIDs)) { + this._rpc({ + model: 'mail.channel', + method: 'channel_info', + args: [toUpdateOutOfOfficeChatIDs], + }).then(function (channelsInfo) { + _.each(channelsInfo, function (channelInfo) { + dmChat = self.getChannel(channelInfo.id); + if (!dmChat) { + return; + } + dmChat.updateOutOfOfficeInfo({ + outOfOfficeMessage: channelInfo.direct_partner[0].out_of_office_message, + outOfOfficeDateEnd: channelInfo.direct_partner[0].out_of_office_date_end, + }); + }); + }); + } if (! _.isEmpty(updatedIDs)) { this._mailBus.trigger('updated_im_status', updatedIDs); // useful for thread window header this._renderImStatus(updatedIDs); |
