diff options
| author | Sébastien Theys <seb@odoo.com> | 2021-01-26 14:03:11 +0000 |
|---|---|---|
| committer | Sébastien Theys <seb@odoo.com> | 2021-01-26 14:03:11 +0000 |
| commit | 8668b3ff8da395738c030e45ff1787efd8b45df3 (patch) | |
| tree | 52f7b732363ffc71afec22afec4ffb4b486bf22d /addons/mail/static/src/models/message/message.js | |
| parent | 63e36a9254c20726b57160b0bd08bc3aa292a063 (diff) | |
[FIX] mail: avoid hiding non-text messages that are not empty
task-2447695
closes odoo/odoo#65061
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
Diffstat (limited to 'addons/mail/static/src/models/message/message.js')
| -rw-r--r-- | addons/mail/static/src/models/message/message.js | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/addons/mail/static/src/models/message/message.js b/addons/mail/static/src/models/message/message.js index e823be99b78..627a8a281f7 100644 --- a/addons/mail/static/src/models/message/message.js +++ b/addons/mail/static/src/models/message/message.js @@ -420,11 +420,34 @@ function factory(dependencies) { } /** + * The method does not attempt to cover all possible cases of empty + * messages, but mostly those that happen with a standard flow. Indeed + * it is preferable to be defensive and show an empty message sometimes + * instead of hiding a non-empty message. + * + * The main use case for when a message should become empty is for a + * message posted with only an attachment (no body) and then the + * attachment is deleted. + * + * The main use case for being defensive with the check is when + * receiving a message that has no textual content but has other + * meaningful HTML tags (eg. just an <img/>). + * * @private + * @returns {boolean} */ _computeIsEmpty() { + const isBodyEmpty = ( + !this.body || + [ + '', + '<p></p>', + '<p><br></p>', + '<p><br/></p>', + ].includes(this.body.replace(/\s/g, '')) + ); return ( - (!this.body || htmlToTextContentInline(this.body) === '') && + isBodyEmpty && this.attachments.length === 0 && this.tracking_value_ids.length === 0 && !this.subtype_description @@ -600,6 +623,7 @@ function factory(dependencies) { dependencies: [ 'attachments', 'body', + 'subtype_description', 'tracking_value_ids', ], }), |
