From 9e515155a64df5b37c70aa6f84d623d04c853e1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 21 Feb 2022 14:06:53 +0000 Subject: [PATCH] [IMP] mail: turn "Chatter/attachmentsLoaderTimeout" into field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2734101 closes odoo/odoo#85012 Signed-off-by: Sébastien Theys (seb) --- .../mail/static/src/models/chatter/chatter.js | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/models/chatter/chatter.js b/addons/mail/static/src/models/chatter/chatter.js index c9411e5e869..19f89aaf07a 100644 --- a/addons/mail/static/src/models/chatter/chatter.js +++ b/addons/mail/static/src/models/chatter/chatter.js @@ -26,11 +26,10 @@ registerModel({ identifyingFields: ['id'], lifecycleHooks: { _created() { - this._attachmentsLoaderTimeout = undefined; this._isPreparingAttachmentsLoading = undefined; }, _willDelete() { - this._stopAttachmentsLoading(); + this.messaging.browser.clearTimeout(this.attachmentsLoaderTimeout); }, }, recordMethods: { @@ -173,6 +172,13 @@ registerModel({ thread: this.thread ? link(this.thread) : unlink(), }); }, + /** + * @private + */ + _onAttachmentsLoadingTimeout() { + this.update({ isShowingAttachmentsLoading: true }); + this._isPreparingAttachmentsLoading = false; + }, /** * @private */ @@ -231,17 +237,19 @@ registerModel({ */ _prepareAttachmentsLoading() { this._isPreparingAttachmentsLoading = true; - this._attachmentsLoaderTimeout = this.messaging.browser.setTimeout(() => { - this.update({ isShowingAttachmentsLoading: true }); - this._isPreparingAttachmentsLoading = false; - }, this.messaging.loadingBaseDelayDuration); + this.update({ + attachmentsLoaderTimeout: this.messaging.browser.setTimeout( + this._onAttachmentsLoadingTimeout, + this.messaging.loadingBaseDelayDuration, + ), + }); }, /** * @private */ _stopAttachmentsLoading() { - this.messaging.browser.clearTimeout(this._attachmentsLoaderTimeout); - this._attachmentsLoaderTimeout = null; + this.messaging.browser.clearTimeout(this.attachmentsLoaderTimeout); + this.update({ attachmentsLoaderTimeout: clear() }); this._isPreparingAttachmentsLoading = false; }, }, @@ -255,6 +263,7 @@ registerModel({ inverse: 'chatter', isCausal: true, }), + attachmentsLoaderTimeout: attr(), /** * States the OWL Chatter component of this chatter. */