diff options
| author | Christophe Simonis <chs@odoo.com> | 2019-07-29 14:10:30 +0200 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2019-07-29 14:10:30 +0200 |
| commit | d5e1fd16b4fd796cc25b2b2d694dadb375110ce7 (patch) | |
| tree | 35d130b4161985cd9ca3071a59980b52e8401be5 /addons/mail/static/src/js/services | |
| parent | ae71f95371b4a5c99c10a23e3553c5badc45a1ac (diff) | |
| parent | cda4f3c308ca233aead81f5ae97d250b5b7bf82f (diff) | |
[MERGE] forward port branch saas-12.4 up to cda4f3c308c
Diffstat (limited to 'addons/mail/static/src/js/services')
4 files changed, 53 insertions, 12 deletions
diff --git a/addons/mail/static/src/js/services/mail_document_thread_manager.js b/addons/mail/static/src/js/services/mail_document_thread_manager.js index f1d9eefb44a..acf06461a04 100644 --- a/addons/mail/static/src/js/services/mail_document_thread_manager.js +++ b/addons/mail/static/src/js/services/mail_document_thread_manager.js @@ -48,23 +48,16 @@ MailManager.include({ * * @override * @param {Object} data - * @param {Array} [data.author_id] [int, string] where int is server ID of - * the author, and string is the name of the author. * @param {integer} data.id server ID of the message - * @param {string} [data.model] the model name of the document that this - * message is related to. - * @param {integer} [data.res_id] the ID of the document that this message - * is related to. - * + * @param {Object} [options] + * @param {boolean} [options.postedFromDocumentThread=false] */ - addMessage: function (data) { + addMessage: function (data, options) { var message = this.getMessage(data.id); if ( !message && - data.res_id && - data.model && - data.author_id && - data.author_id[0] === session.partner_id + options && + options.postedFromDocumentThread ) { var key = this.DOCUMENT_THREAD_MESSAGE_KEY; this.call('local_storage', 'setItem', key, data); diff --git a/addons/mail/static/src/js/services/mail_notification_manager.js b/addons/mail/static/src/js/services/mail_notification_manager.js index caf0c3c4e12..c22276867b1 100644 --- a/addons/mail/static/src/js/services/mail_notification_manager.js +++ b/addons/mail/static/src/js/services/mail_notification_manager.js @@ -417,6 +417,9 @@ MailManager.include({ this._handlePartnerUserConnectionNotification(data); } else if (data.info === 'channel_seen') { this._handlePartnerChannnelSeenNotification(data); + } else if (data.type === 'simple_notification') { + var title = _.escape(data.title), message = _.escape(data.message); + data.warning ? this.do_warn(title, message, data.sticky) : this.do_notify(title, message, data.sticky); } else { this._handlePartnerChannelNotification(data); } 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); diff --git a/addons/mail/static/src/js/services/mail_window_manager.js b/addons/mail/static/src/js/services/mail_window_manager.js index 6214fc8b5b7..81f0ef7e97c 100644 --- a/addons/mail/static/src/js/services/mail_window_manager.js +++ b/addons/mail/static/src/js/services/mail_window_manager.js @@ -344,6 +344,7 @@ MailManager.include({ .on('is_thread_bottom_visible', this, this._onIsThreadBottomVisible) .on('unsubscribe_from_channel', this, this._onUnsubscribeFromChannel) .on('updated_im_status', this, this._onUpdatedImStatus) + .on('updated_out_of_office', this, this._onUpdatedOutOfOffice) .on('update_thread_unread_counter', this, this._onUpdateThreadUnreadCounter); core.bus.on('resize', this, _.debounce(this._repositionThreadWindows.bind(this), 100)); @@ -701,6 +702,18 @@ MailManager.include({ }); }, /** + * @private + * @param {Object} data + * @param {integer} data.threadID + */ + _onUpdatedOutOfOffice: function (data) { + var threadWindow = this._getThreadWindow(data.threadID); + if (!threadWindow) { + return; + } + threadWindow.renderOutOfOffice(); + }, + /** * Called when a thread has its unread counter that has changed. * The unread counter on the thread windows should be updated. * |
