From 1bc57cd96ec63e8698cdc6f9071d149e5e2282c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Theys?= Date: Wed, 8 Jun 2022 14:51:47 +0000 Subject: [PATCH] [IMP] mail: move hasParentReloadOnMessagePosted to models Remove code from legacy form in preparation of Owl form. Part of task-2871070 Part-of: odoo/odoo#93273 --- .../src/components/chatter_container/chatter_container.js | 4 ++++ addons/mail/static/src/models/chatter.js | 3 +++ addons/mail/static/src/models/composer_view.js | 4 ++++ .../mail/static/src/widgets/form_renderer/form_renderer.js | 7 +------ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/addons/mail/static/src/components/chatter_container/chatter_container.js b/addons/mail/static/src/components/chatter_container/chatter_container.js index 2f1e38045dc..0c45751d44f 100644 --- a/addons/mail/static/src/components/chatter_container/chatter_container.js +++ b/addons/mail/static/src/components/chatter_container/chatter_container.js @@ -121,6 +121,10 @@ Object.assign(ChatterContainer, { type: Boolean, optional: true, }, + hasParentReloadOnMessagePosted: { + type: Boolean, + optional: true, + }, hasTopbarCloseButton: { type: Boolean, optional: true, diff --git a/addons/mail/static/src/models/chatter.js b/addons/mail/static/src/models/chatter.js index cfa6bca3a03..115f2be1ba4 100644 --- a/addons/mail/static/src/models/chatter.js +++ b/addons/mail/static/src/models/chatter.js @@ -422,6 +422,9 @@ registerModel({ hasParentReloadOnFollowersUpdate: attr({ default: false, }), + hasParentReloadOnMessagePosted: attr({ + default: false, + }), /** * Determines whether `this.thread` should be displayed. */ diff --git a/addons/mail/static/src/models/composer_view.js b/addons/mail/static/src/models/composer_view.js index ea2c25347ea..65d69f3afbf 100644 --- a/addons/mail/static/src/models/composer_view.js +++ b/addons/mail/static/src/models/composer_view.js @@ -586,6 +586,7 @@ registerModel({ postData.parent_id = this.threadView.replyingToMessageView.message.id; } const { threadView = {} } = this; + const chatter = this.chatter; const { thread: chatterThread } = this.chatter || {}; const { thread: threadViewThread } = threadView; const messageData = await this.messaging.rpc({ route: `/mail/message/post`, params }); @@ -600,6 +601,9 @@ registerModel({ threadView.update({ hasAutoScrollOnMessageReceived: true }); threadView.addComponentHint('message-posted', { message }); } + if (chatter && chatter.exists() && chatter.hasParentReloadOnMessagePosted) { + chatter.reloadParentView(); + } if (chatterThread) { if (this.exists()) { this.delete(); diff --git a/addons/mail/static/src/widgets/form_renderer/form_renderer.js b/addons/mail/static/src/widgets/form_renderer/form_renderer.js index dc0a4576dcb..549c3bc38c7 100644 --- a/addons/mail/static/src/widgets/form_renderer/form_renderer.js +++ b/addons/mail/static/src/widgets/form_renderer/form_renderer.js @@ -41,7 +41,6 @@ FormRenderer.include({ this._super(...arguments); this._chatterContainerComponent = undefined; this.off('o_chatter_rendered', this); - this.off('o_message_posted', this); }, //-------------------------------------------------------------------------- @@ -71,11 +70,6 @@ FormRenderer.include({ // Not in custom_events because other modules may remove this listener // while attempting to extend them. this.on('o_chatter_rendered', this, ev => this._onChatterRendered(ev)); - if (this.chatterFields.hasRecordReloadOnMessagePosted) { - this.on('o_message_posted', this, ev => { - this.trigger_up('reload', { keepChanges: true }); - }); - } }, /** * @private @@ -88,6 +82,7 @@ FormRenderer.include({ hasMessageList: this.chatterFields.hasMessageIds, hasParentReloadOnAttachmentsChanged: this.chatterFields.hasRecordReloadOnAttachmentsChanged, hasParentReloadOnFollowersUpdate: this.chatterFields.hasRecordReloadOnFollowersUpdate, + hasParentReloadOnMessagePosted: this.chatterFields.hasRecordReloadOnMessagePosted, isAttachmentBoxVisibleInitially: this.chatterFields.isAttachmentBoxVisibleInitially, threadId: this.state.res_id, threadModel: this.state.model,