From cd26eaff6af44ea66b119fdd8d78648621966143 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Mon, 17 Oct 2022 22:41:39 +0200 Subject: [PATCH] Update CustomQuoter.plugin.js --- Plugins/CustomQuoter/CustomQuoter.plugin.js | 26 ++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/Plugins/CustomQuoter/CustomQuoter.plugin.js b/Plugins/CustomQuoter/CustomQuoter.plugin.js index c9a6eca249..8493a2e142 100644 --- a/Plugins/CustomQuoter/CustomQuoter.plugin.js +++ b/Plugins/CustomQuoter/CustomQuoter.plugin.js @@ -2,7 +2,7 @@ * @name CustomQuoter * @author DevilBro * @authorId 278543574059057154 - * @version 1.3.0 + * @version 1.3.1 * @description Brings back the Quote Feature and allows you to set your own Quote Formats * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -56,7 +56,7 @@ module.exports = (_ => { return template.content.firstElementChild; } } : (([Plugin, BDFDB]) => { - var _this, ChannelTextAreaForm; + var _this, ChannelTextAreaContainer; var formats = {}, format = null; const PreviewMessageComponent = class PreviewMessage extends BdApi.React.Component { @@ -98,10 +98,14 @@ module.exports = (_ => { onLoad () { _this = this; - this.patchedModules = { - before: { - ChannelTextAreaForm: "render" - } + this.modulePatches = { + before: [ + "ChannelTextAreaContainer" + ], + after: [ + "MessageActionsContextMenu", + "MessageToolbar" + ] }; this.defaults = { @@ -313,7 +317,7 @@ module.exports = (_ => { } } - onMessageOptionContextMenu (e) { + processMessageActionsContextMenu (e) { if (e.instance.props.message && e.instance.props.channel) { let [quoteChildren, quoteIndex] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "quote"}); if (quoteIndex == -1) { @@ -333,7 +337,7 @@ module.exports = (_ => { } } - onMessageOptionToolbar (e) { + processMessageToolbar (e) { if ((e.instance.props.expanded || !this.settings.general.holdShiftToolbar) && e.instance.props.message && e.instance.props.channel) { let quoteButton = BDFDB.ReactUtils.findChild(e.returnvalue, {key: "quote"}); if (!quoteButton) { @@ -356,8 +360,8 @@ module.exports = (_ => { } } - processChannelTextAreaForm (e) { - ChannelTextAreaForm = e.instance; + processChannelTextAreaContainer (e) { + if (e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY) ChannelTextAreaContainer = e.instance } quote (channel, message, shift) { @@ -368,7 +372,7 @@ module.exports = (_ => { BDFDB.NotificationUtils.toast(this.labels.toast_quotecopied, {type: "success"}); } else BDFDB.LibraryModules.DispatchUtils.ComponentDispatch.dispatchToLastSubscribed(BDFDB.DiscordConstants.ComponentActions.INSERT_TEXT, { - plainText: [this.settings.general.autoAddNewLine && ChannelTextAreaForm && ChannelTextAreaForm.state.textValue && !this.isNewLine(ChannelTextAreaForm.state.textValue, true) && !this.isNewLine(text, false) && "\n", text, this.settings.general.autoAddNewLine && !this.isNewLine(text, true) && "\n"].filter(n => n).join("") + plainText: [this.settings.general.autoAddNewLine && ChannelTextAreaContainer && ChannelTextAreaContainer.props.textValue && !this.isNewLine(ChannelTextAreaContainer.props.textValue, true) && !this.isNewLine(text, false) && "\n", text, this.settings.general.autoAddNewLine && !this.isNewLine(text, true) && "\n"].filter(n => n).join("") }); } }