[IMP] mail: turn "Chatter/attachmentsLoaderTimeout" into field

Task-2734101

closes odoo/odoo#85012

Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
This commit is contained in:
Alexandre Kühn
2022-02-21 20:11:59 +00:00
parent 030b1ba8d6
commit 9e515155a6
@@ -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.
*/