From 1bc7976f951997013647b1484d10dec19e93435e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20K=C3=BChn?= Date: Mon, 21 Feb 2022 14:12:18 +0000 Subject: [PATCH] [IMP] mail: turn "Chatter/isPreparingAttachmentsLoading" into field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-2734101 closes odoo/odoo#85015 Signed-off-by: Sébastien Theys (seb) --- .../mail/static/src/models/chatter/chatter.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/models/chatter/chatter.js b/addons/mail/static/src/models/chatter/chatter.js index 19f89aaf07a..b74bcf7f072 100644 --- a/addons/mail/static/src/models/chatter/chatter.js +++ b/addons/mail/static/src/models/chatter/chatter.js @@ -25,9 +25,6 @@ registerModel({ name: 'Chatter', identifyingFields: ['id'], lifecycleHooks: { - _created() { - this._isPreparingAttachmentsLoading = undefined; - }, _willDelete() { this.messaging.browser.clearTimeout(this.attachmentsLoaderTimeout); }, @@ -161,6 +158,13 @@ registerModel({ _computeIsDisabled() { return Boolean(!this.thread || this.thread.isTemporary); }, + /** + * @private + * @returns {boolean} + */ + _computeIsPreparingAttachmentsLoading() { + return this.attachmentsLoaderTimeout !== undefined; + }, /** * @private * @returns {ThreadViewer} @@ -176,8 +180,10 @@ registerModel({ * @private */ _onAttachmentsLoadingTimeout() { - this.update({ isShowingAttachmentsLoading: true }); - this._isPreparingAttachmentsLoading = false; + this.update({ + attachmentsLoaderTimeout: clear(), + isShowingAttachmentsLoading: true, + }); }, /** * @private @@ -227,7 +233,7 @@ registerModel({ this.update({ isShowingAttachmentsLoading: false }); return; } - if (this._isPreparingAttachmentsLoading || this.isShowingAttachmentsLoading) { + if (this.isPreparingAttachmentsLoading || this.isShowingAttachmentsLoading) { return; } this._prepareAttachmentsLoading(); @@ -236,7 +242,6 @@ registerModel({ * @private */ _prepareAttachmentsLoading() { - this._isPreparingAttachmentsLoading = true; this.update({ attachmentsLoaderTimeout: this.messaging.browser.setTimeout( this._onAttachmentsLoadingTimeout, @@ -250,7 +255,6 @@ registerModel({ _stopAttachmentsLoading() { this.messaging.browser.clearTimeout(this.attachmentsLoaderTimeout); this.update({ attachmentsLoaderTimeout: clear() }); - this._isPreparingAttachmentsLoading = false; }, }, fields: { @@ -340,6 +344,10 @@ registerModel({ compute: '_computeIsDisabled', default: false, }), + isPreparingAttachmentsLoading: attr({ + compute: '_computeIsPreparingAttachmentsLoading', + default: false, + }), isShowingAttachmentsLoading: attr({ default: false, }),