From 376d7c451ebd1b73249e19ac0dfa90751ee4637f Mon Sep 17 00:00:00 2001 From: Mirco Wittrien <23700969+mwittrien@users.noreply.github.com> Date: Fri, 8 Jul 2022 16:07:07 +0200 Subject: [PATCH] Revert "Update EditChannels.plugin.js" This reverts commit 4b57277dbf74ea6f5c2c1410e84bda87434cd0ee. --- Plugins/EditChannels/EditChannels.plugin.js | 73 ++++++++++----------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/Plugins/EditChannels/EditChannels.plugin.js b/Plugins/EditChannels/EditChannels.plugin.js index cdf5faad18..ab2893dede 100644 --- a/Plugins/EditChannels/EditChannels.plugin.js +++ b/Plugins/EditChannels/EditChannels.plugin.js @@ -2,7 +2,7 @@ * @name EditChannels * @author DevilBro * @authorId 278543574059057154 - * @version 4.3.9 + * @version 4.3.8 * @description Allows you to locally edit Channels * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -17,7 +17,7 @@ module.exports = (_ => { "info": { "name": "EditChannels", "author": "DevilBro", - "version": "4.3.9", + "version": "4.3.8", "description": "Allows you to locally edit Channels" } }; @@ -222,51 +222,50 @@ module.exports = (_ => { } onChannelContextMenu (e) { - if (e.instance.props.channel && e.subType == "useChannelDeleteItem") { - if (e.returnvalue.length) e.returnvalue.push(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSeparator, {})); - e.returnvalue.push(this.createMenuItem(e.instance.props.channel)); - } + this.injectItem(e); } onGroupDMContextMenu (e) { + this.injectItem(e); + } + + injectItem (e) { if (e.instance.props.channel) { let [children, index] = BDFDB.ContextMenuUtils.findItem(e.returnvalue, {id: "devmode-copy-id", group: true}); children.splice(index > -1 ? index : children.length, 0, BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: this.createMenuItem(e.instance.props.channel) + children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: this.labels.context_localchannelsettings, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-submenu"), + children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { + children: [ + BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: this.labels.submenu_channelsettings, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-change"), + action: _ => { + this.openChannelSettingsModal(e.instance.props.channel); + } + }), + BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { + label: this.labels.submenu_resetsettings, + id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), + color: BDFDB.LibraryComponents.MenuItems.Colors.DANGER, + disabled: !changedChannels[e.instance.props.channel.id], + action: event => { + let remove = _ => { + BDFDB.DataUtils.remove(this, "channels", e.instance.props.channel.id); + this.forceUpdateAll(true); + }; + if (event.shiftKey) remove(); + else BDFDB.ModalUtils.confirm(this, this.labels.confirm_reset, remove); + } + }) + ] + }) + }) })); } } - createMenuItem (channel) { - return BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.context_localchannelsettings, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-submenu"), - children: BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuGroup, { - children: [ - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.submenu_channelsettings, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-change"), - action: _ => this.openChannelSettingsModal(channel) - }), - BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { - label: this.labels.submenu_resetsettings, - id: BDFDB.ContextMenuUtils.createItemId(this.name, "settings-reset"), - color: BDFDB.LibraryComponents.MenuItems.Colors.DANGER, - disabled: !changedChannels[channel.id], - action: event => { - let remove = _ => { - BDFDB.DataUtils.remove(this, "channels", channel.id); - this.forceUpdateAll(true); - }; - if (event.shiftKey) remove(); - else BDFDB.ModalUtils.confirm(this, this.labels.confirm_reset, remove); - } - }) - ] - }) - }); - } - processChannelEditorContainer (e) { if (!e.instance.props.disabled && e.instance.props.channel && changedChannels[e.instance.props.channel.id] && (e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) && this.settings.places.chatTextarea) { if (changedChannels[e.instance.props.channel.id].name) e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${changedChannels[e.instance.props.channel.id].name}`);