Skip to content

Commit 0722e88

Browse files
authored
fix: Fix: Properly remove event listeners in NoteAttachment's beforeDestroy - EXO-77998 (#2467) (#2479)
Prior to this change, a console error was displayed in the note attachments extension. This error occurred due to incorrect removal of event listeners. This change ensures that event listeners are removed correctly.
1 parent 0cb0764 commit 0722e88

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

apps/portlet-documents/src/main/webapp/vue-app/attachment/components/notes/NotesAttachment.vue

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,21 +100,14 @@ export default {
100100
}
101101
document.addEventListener('open-notes-attachments', this.openAttachmentDrawer);
102102
document.addEventListener('attachments-app-drawer-closed', this.handleDrawerClosedEvent);
103-
document.addEventListener('note-draft-auto-save-done', (event) => {
104-
if (this.attachmentListUpdated && event.detail.draftId) {
105-
this.updateLinkedAttachmentsToEntity(event.detail.draftId);
106-
}
107-
});
108-
document.addEventListener('article-draft-auto-save-done', (event) => {
109-
if (this.attachmentListUpdated && event.detail.draftId) {
110-
this.updateLinkedAttachmentsToEntity(event.detail.draftId);
111-
}
112-
});
103+
document.addEventListener('note-draft-auto-save-done', this.handleDraftAutoSave);
104+
document.addEventListener('article-draft-auto-save-done', this.handleDraftAutoSave);
113105
},
114106
beforeDestroy() {
115107
document.removeEventListener('open-notes-attachments', this.openAttachmentDrawer);
116108
document.removeEventListener('attachments-app-drawer-closed', this.handleDrawerClosedEvent);
117-
document.removeEventListener('article-draft-auto-save-done');
109+
document.removeEventListener('article-draft-auto-save-done', this.handleDraftAutoSave);
110+
document.removeEventListener('note-draft-auto-save-done', this.handleDraftAutoSave);
118111
},
119112
methods: {
120113
openAttachmentDrawer() {
@@ -202,6 +195,11 @@ export default {
202195
});
203196
}
204197
},
198+
handleDraftAutoSave(event) {
199+
if (this.attachmentListUpdated && event.detail.draftId) {
200+
this.updateLinkedAttachmentsToEntity(event.detail.draftId);
201+
}
202+
}
205203
}
206204
};
207205
</script>

0 commit comments

Comments
 (0)