From 35ef35fa8a83c9cec179e1533adec70e0cbf9e04 Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Fri, 9 Aug 2024 09:49:20 +0200 Subject: [PATCH] FIX: attempts to use new modifyClass syntax I suspect it might help cases where the save function is not called for this theme. --- javascripts/discourse/initializers/init.js | 32 ++++++++++++---------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/javascripts/discourse/initializers/init.js b/javascripts/discourse/initializers/init.js index 4aacff1..9e91dcb 100644 --- a/javascripts/discourse/initializers/init.js +++ b/javascripts/discourse/initializers/init.js @@ -42,22 +42,24 @@ export default { }, }); - api.modifyClass("controller:composer", { - pluginId: "unformatted-code-detector", - - save(...args) { - if ( - this.model.ucd_checkUnformattedCodeDetected() && - !this.model.ucd_checkShouldIgnoreWarning() - ) { - this.modal.show(ModalUcdWarning, { - model: this.model, - }); - } else { - this._super(...args); + api.modifyClass( + "controller:composer", + (Superclass) => + class extends Superclass { + save(...args) { + if ( + this.model.ucd_checkUnformattedCodeDetected() && + !this.model.ucd_checkShouldIgnoreWarning() + ) { + this.modal.show(ModalUcdWarning, { + model: this.model, + }); + } else { + super.save(...args); + } + } } - }, - }); + ); }); }, };