From 96d6c7ec69aa8581022e61d48d4ea76588e14769 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 6 Sep 2016 13:25:12 +0200 Subject: [PATCH] Fixed attachments not being cleaned up --- wcfsetup/install/files/js/WCF.Attachment.js | 14 +++++++++++--- .../WoltLabSuite/Core/Ui/Message/InlineEditor.js | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.Attachment.js b/wcfsetup/install/files/js/WCF.Attachment.js index 976398d32f..954227665d 100644 --- a/wcfsetup/install/files/js/WCF.Attachment.js +++ b/wcfsetup/install/files/js/WCF.Attachment.js @@ -84,10 +84,10 @@ WCF.Attachment.Upload = WCF.Upload.extend({ } if (this._editorId) { - WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'submit_' + this._editorId, $.proxy(this._submitInline, this)); - WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'reset_' + this._editorId, $.proxy(this._reset, this)); + WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'submit_' + this._editorId, this._submitInline.bind(this)); + WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'reset_' + this._editorId, this._reset.bind(this)); - WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'metacode_attach', (function(data) { + var metacodeAttachUuid = WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'metacode_attach', (function(data) { var images = this._getImageAttachments(); var attachmentId = data.attributes[0] || 0; if (images.hasOwnProperty(attachmentId)) { @@ -111,6 +111,14 @@ WCF.Attachment.Upload = WCF.Upload.extend({ } }).bind(this)); + WCF.System.Event.addListener('com.woltlab.wcf.redactor2', 'destroy_' + this._editorId, (function () { + WCF.System.Event.removeAllListeners('com.woltlab.wcf.redactor2', 'submit_' + this._editorId); + WCF.System.Event.removeAllListeners('com.woltlab.wcf.redactor2', 'reset_' + this._editorId); + WCF.System.Event.removeAllListeners('com.woltlab.wcf.redactor2', 'insertAttachment_' + this._editorId); + + WCF.System.Event.removeListener('com.woltlab.wcf.redactor2', 'metacode_attach', metacodeAttachUuid); + }).bind(this)); + // TODO //WCF.System.Event.addListener('com.woltlab.wcf.redactor', 'upload_' + this._editorId, $.proxy(this._editorUpload, this)); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js index 45c9e377bf..905952c395 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js @@ -599,7 +599,7 @@ define( */ _destroyEditor: function() { EventHandler.fire('com.woltlab.wcf.redactor2', 'autosaveDestroy_' + this._getEditorId()); - EventHandler.fire('com.woltlab.wcf.redactor', 'destroy_' + this._getEditorId()); + EventHandler.fire('com.woltlab.wcf.redactor2', 'destroy_' + this._getEditorId()); }, /** -- 2.20.1