Update EditChannels.plugin.js

This commit is contained in:
Mirco Wittrien 2021-06-25 20:59:12 +02:00
parent e4b989ffd0
commit 5d651d593c
1 changed files with 20 additions and 15 deletions

View File

@ -2,7 +2,7 @@
* @name EditChannels * @name EditChannels
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 4.3.1 * @version 4.3.2
* @description Allows you to locally edit Channels * @description Allows you to locally edit Channels
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -17,14 +17,12 @@ module.exports = (_ => {
"info": { "info": {
"name": "EditChannels", "name": "EditChannels",
"author": "DevilBro", "author": "DevilBro",
"version": "4.3.1", "version": "4.3.2",
"description": "Allows you to locally edit Channels" "description": "Allows you to locally edit Channels"
}, },
"changeLog": { "changeLog": {
"fixed": { "fixed": {
"Group DMs": "Fixed some stuff in Group DMs", "Autocomplete Menu": ""
"Show Hidden Channels": "Fixed some Issues with the fake category created by ShowHiddenChannels",
"Color Inherit": "Works again"
} }
} }
}; };
@ -157,8 +155,8 @@ module.exports = (_ => {
catData catData
}, changedChannels[id])); }, changedChannels[id]));
} }
channelArray = BDFDB.ArrayUtils.keySort(channelArray.filter(n => e.returnValue.channels.every(channel => channel.id != n.channel.id) && (n.lowerCaseName.indexOf(e.methodArguments[1]) != -1 || (n.lowerCaseCatName && n.lowerCaseCatName.indexOf(e.methodArguments[1]) != -1))), "lowerCaseName"); channelArray = BDFDB.ArrayUtils.keySort(channelArray.filter(n => e.returnValue.results.channels.every(channel => channel.id != n.channel.id) && (n.lowerCaseName.indexOf(e.methodArguments[2].toLowerCase()) != -1 || (n.lowerCaseCatName && n.lowerCaseCatName.indexOf(e.methodArguments[2].toLowerCase()) != -1))), "lowerCaseName");
e.returnValue.channels = [].concat(e.returnValue.channels, channelArray.map(n => n.channel)).slice(0, BDFDB.DiscordConstants.MAX_AUTOCOMPLETE_RESULTS); e.returnValue.results.channels = [].concat(e.returnValue.results.channels, channelArray.map(n => n.channel)).slice(0, BDFDB.DiscordConstants.MAX_AUTOCOMPLETE_RESULTS);
}}); }});
this.forceUpdateAll(); this.forceUpdateAll();
@ -284,14 +282,21 @@ module.exports = (_ => {
if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id); if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id);
} }
else { else {
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "AutocompleteRowHeading"}); if (typeof e.returnvalue.props.children == "function") {
let childrenRender = e.returnvalue.props.children;
e.returnvalue.props.children = (...args) => {
let children = childrenRender(...args);
let channelName = BDFDB.ReactUtils.findChild(children, {name: "AutocompleteRowHeading"});
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id); if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id);
let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.autocompleteicon]]}); let channelIcon = BDFDB.ReactUtils.findChild(children, {props: [["className", BDFDB.disCN.autocompleteicon]]});
if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id); if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id);
if (e.instance.props.category) { if (e.instance.props.category) {
let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "AutocompleteRowContentSecondary"}); let categoryName = BDFDB.ReactUtils.findChild(children, {name: "AutocompleteRowContentSecondary"});
if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id); if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id);
} }
return children;
};
}
} }
} }
} }
@ -587,7 +592,7 @@ module.exports = (_ => {
if (this.settings.places.appTitle) { if (this.settings.places.appTitle) {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId()); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(BDFDB.LibraryModules.LastChannelStore.getChannelId());
let title = document.head.querySelector("title"); let title = document.head.querySelector("title");
if (title && changedChannels[channel.id] && changedChannels[channel.id].name) { if (title && channel && changedChannels[channel.id] && changedChannels[channel.id].name) {
if (BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "#" + this.getChannelData(channel.id).name); if (BDFDB.ChannelUtils.isTextChannel(channel)) BDFDB.DOMUtils.setText(title, "#" + this.getChannelData(channel.id).name);
else if (channel && channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id)); else if (channel && channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id));
} }