[FIX] mail: prevents traceback when clicking attachment unlink button

Before this commit, quickly clicking on the unlink button of an
attachment could result in a traceback if the click happened right
after the deletion of attachment but before the rendering of the DOM.

part of task-2363522

closes odoo/odoo#63447

X-original-commit: 1858184394342f24f5456728c4255f9980220c20
Signed-off-by: Sébastien Theys (seb) <seb@odoo.com>
Signed-off-by: Alexandre Kühn (aku) <aku@odoo.com>
This commit is contained in:
Thanh Dodeur
2020-12-16 13:04:51 +00:00
parent fd0ff95f23
commit cdb469bce5
@@ -131,6 +131,9 @@ class Attachment extends Component {
*/
_onClickUnlink(ev) {
ev.stopPropagation();
if (!this.attachment) {
return;
}
if (this.attachment.isLinkedToComposer) {
this.attachment.remove();
this.trigger('o-attachment-removed', { attachmentLocalId: this.props.attachmentLocalId });