Skip to content

Commit

Permalink
FIX: attempts to use new modifyClass syntax
Browse files Browse the repository at this point in the history
I suspect it might help cases where the save function is not called for this theme.
  • Loading branch information
jjaffeux committed Aug 9, 2024
1 parent 11ec273 commit 35ef35f
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions javascripts/discourse/initializers/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
},
});
);
});
},
};

0 comments on commit 35ef35f

Please sign in to comment.