Fixed attachments not being cleaned up
authorAlexander Ebert <ebert@woltlab.com>
Tue, 6 Sep 2016 11:25:12 +0000 (13:25 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 6 Sep 2016 11:25:12 +0000 (13:25 +0200)
wcfsetup/install/files/js/WCF.Attachment.js
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Message/InlineEditor.js

index 976398d32fa59d2f4ba93fe73af9397e3841fd12..954227665d523abca39f87d9e95ef2df63641549 100644 (file)
@@ -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));
                }
index 45c9e377bfaa84e39de832e046962779595ba62b..905952c3954133698cce8f65d0415409a08f284d 100644 (file)
@@ -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());
                },
                
                /**