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. */