summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js/services/mail_status_manager.js
diff options
context:
space:
mode:
authorAlexandre Kühn <aku@odoo.com>2019-06-13 13:53:01 +0000
committerAlexandre Kühn <aku@odoo.com>2019-07-16 14:36:44 +0000
commitbdf45dca506f9938bfcd3a7acc8757a16d701d05 (patch)
treedbe074599045aef04eb18935eef2859d555a14c5 /addons/mail/static/src/js/services/mail_status_manager.js
parent4bde721f925bfe3d1e867565490d3830da150dcc (diff)
[FIX] mail: auto-update out-of-office info on im_status change
Before this commit, chat window's out-of-office info did not change when direct partner's `im_status` is/was on 'leave'. Users had to reload page to see updated out-of-office info. Task-ID 2007663
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.js32
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 3addaf65349..6f9b996f231 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);