diff options
| author | Alexandre Kühn <aku@odoo.com> | 2019-09-17 15:10:01 +0000 |
|---|---|---|
| committer | Alexandre Kühn <aku@odoo.com> | 2019-09-18 10:07:20 +0000 |
| commit | 9a66619db33fca5f0cb81d9f6bfeb0fb0290cf68 (patch) | |
| tree | 7f89fa455784ec93ec9d003f515b0d0ea5834a17 /addons/mail/static/src/js/thread_field.js | |
| parent | 3dd2e7c2ef34d76a953089c5a0939ecf3152498e (diff) | |
[FIX] mail: no wait init_messaging before loading webclient
Before this commit, discuss widgets had to wait for the route
`mail/init_messaging`. This behaviour slowed down the loading of the
web client.
This commit solves the issue by rendering discuss widgets even when
`mail/init_messaging` hasn't been resolved. For instance, the
messaging menu displays a spinner until messaging becomes ready.
Task-Id 2072835
closes odoo/odoo#37031
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/js/thread_field.js')
| -rw-r--r-- | addons/mail/static/src/js/thread_field.js | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/addons/mail/static/src/js/thread_field.js b/addons/mail/static/src/js/thread_field.js index ab8023b06ad..c8a59850016 100644 --- a/addons/mail/static/src/js/thread_field.js +++ b/addons/mail/static/src/js/thread_field.js @@ -20,6 +20,9 @@ var ThreadField = AbstractField.extend({ */ init: function () { this._super.apply(this, arguments); + this._isMessagingReady = this.call('mail_service', 'isReady'); + this._isStarted = false; + this.call('mail_service', 'getMailBus').on('messaging_ready', this, this._onMessagingReady); // Used to automatically mark document thread as read at the moment we // access the document and render the thread. this._markAsReadOnNextRender = false; @@ -28,15 +31,10 @@ var ThreadField = AbstractField.extend({ /** * @override */ - willStart: function () { - return this.alive(this.call('mail_service', 'isReady')); - }, - /** - * @override - */ start: function () { var self = this; + this._isStarted = true; this.dp = new concurrency.DropPrevious(); this._threadWidget = new ThreadWidget(this, { @@ -159,6 +157,9 @@ var ThreadField = AbstractField.extend({ * If it is a new document in create mode, unset the document thread. */ _setDocumentThread: function () { + if (!this._isMessagingReady) { + return; + } var params = { messageIDs: this.value.res_ids, name: this.recordData.display_name, @@ -187,6 +188,19 @@ var ThreadField = AbstractField.extend({ }, /** * @private + */ + _onMessagingReady: function () { + if (this._isMessagingReady) { + return; + } + this._isMessagingReady = true; + if (!this._isStarted) { + return; + } + this._setDocumentThread(); + }, + /** + * @private * @param {mail.model.Message} */ _onNewMessage: function (message) { |
