Update EditChannels.plugin.js

This commit is contained in:
Mirco Wittrien 2020-06-27 21:02:12 +02:00
parent f7bd4ea0ea
commit 1544e9534c
1 changed files with 43 additions and 45 deletions

View File

@ -6,7 +6,7 @@ var EditChannels = (_ => {
return class EditChannels { return class EditChannels {
getName () {return "EditChannels";} getName () {return "EditChannels";}
getVersion () {return "4.1.3";} getVersion () {return "4.1.4";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
@ -14,7 +14,7 @@ var EditChannels = (_ => {
constructor () { constructor () {
this.changelog = { this.changelog = {
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]] "fixed":[["Inbox update","Fixes for the inbox update"]]
}; };
this.patchedModules = { this.patchedModules = {
@ -37,14 +37,15 @@ var EditChannels = (_ => {
ChannelCategoryItem: "render", ChannelCategoryItem: "render",
ChannelItem: "render", ChannelItem: "render",
QuickSwitchChannelResult: "render", QuickSwitchChannelResult: "render",
MessagesPopout: "render" RecentsChannelHeader: "default"
} }
}; };
} }
initConstructor () { initConstructor () {
this.css = ` this.css = `
${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"] { ${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"],
${BDFDB.dotCN.recentmentionschannelname}:hover > span[style*="color"] {
text-decoration: underline; text-decoration: underline;
} }
${BDFDB.dotCN.categorywrapper}:hover ${BDFDB.dotCN.categoryname} span[style*="color"], ${BDFDB.dotCN.categorywrapper}:hover ${BDFDB.dotCN.categoryname} span[style*="color"],
@ -233,13 +234,13 @@ var EditChannels = (_ => {
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 [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.marginleft4]]}); let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.marginleft4]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id); if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id);
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.autocompleteicon]]}); let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.autocompleteicon]]});
if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, {alpha: 0.6}); if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, {alpha: 0.6});
if (e.instance.props.category) { if (e.instance.props.category) {
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.autocompletedescription]]}); let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.autocompletedescription]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.category.id); if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id);
} }
} }
} }
@ -250,8 +251,8 @@ var EditChannels = (_ => {
if (channel && settings.changeInAuditLog) { if (channel && settings.changeInAuditLog) {
if (!e.returnvalue) e.instance.props.log.options.channel = this.getChannelData(channel.id); if (!e.returnvalue) e.instance.props.log.options.channel = this.getChannelData(channel.id);
else { else {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["children", [["#" + channel.name]]]]}); let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["children", [["#" + channel.name]]]]});
if (index > -1) this.changeChannelColor(children[index], channel.id); if (channelName) this.changeChannelColor(channelName, channel.id);
} }
} }
} }
@ -267,10 +268,10 @@ var EditChannels = (_ => {
let channel = BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.channelId); let channel = BDFDB.LibraryModules.ChannelStore.getChannel(e.instance.props.channelId);
if (channel && BDFDB.ChannelUtils.isTextChannel(channel) && settings.changeInChannelHeader) { if (channel && BDFDB.ChannelUtils.isTextChannel(channel) && settings.changeInChannelHeader) {
if (!e.returnvalue) { if (!e.returnvalue) {
let [children, index] = BDFDB.ReactUtils.findParent(e.instance, {name: "Title"}); let channelName = BDFDB.ReactUtils.findChild(e.instance, {name: "Title"});
if (index > -1) { if (channelName) {
children[index].props.children = this.getChannelData(channel.id).name; channelName.props.children = this.getChannelData(channel.id).name;
this.changeChannelColor(children[index], channel.id); this.changeChannelColor(channelName, channel.id);
} }
} }
else { else {
@ -294,10 +295,10 @@ var EditChannels = (_ => {
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
else { else {
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected"); let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected");
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.categoryname]]}); let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.categoryname]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); if (categoryName) this.changeChannelColor(categoryName, e.instance.props.channel.id, modify);
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.categoryicon]]}); let categoryIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.categoryicon]]});
if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); if (categoryIcon) this.changeChannelIconColor(categoryIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify));
} }
} }
} }
@ -307,10 +308,10 @@ var EditChannels = (_ => {
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id); if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
else { else {
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected"); let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected");
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.channelname]]}); let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.channelname]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify);
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.channelicon]]}); let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.channelicon]]});
if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify));
} }
} }
} }
@ -323,33 +324,30 @@ var EditChannels = (_ => {
} }
else { else {
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "focused", "unread", "mentions"); let modify = BDFDB.ObjectUtils.extract(e.instance.props, "focused", "unread", "mentions");
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultmatch]]}); let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultmatch]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.channel.id, modify); if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify);
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresulticon]]}); let channelIcon = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresulticon]]});
if (index > -1) this.changeChannelIconColor(children[index], e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify)); if (channelIcon) this.changeChannelIconColor(channelIcon, e.instance.props.channel.id, Object.assign({alpha: 0.6}, modify));
if (e.instance.props.category) { if (e.instance.props.category) {
[children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultnote]]}); let categoryName = BDFDB.ReactUtils.findChild(e.returnvalue, {props:[["className", BDFDB.disCN.quickswitchresultnote]]});
if (index > -1) this.changeChannelColor(children[index], e.instance.props.category.id); if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id);
} }
} }
} }
} }
processMessagesPopout (e) { processRecentsChannelHeader (e) {
if (settings.changeInRecentMentions) { if (settings.changeInRecentMentions && BDFDB.ArrayUtils.is(e.returnvalue.props.children)) {
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "VerticalScroller"}); for (let child of e.returnvalue.props.children) if (child && child.props && child.props.channel) {
if (index > -1 && children[index].props.children && BDFDB.ArrayUtils.is(children[index].props.children[0])) for (let i in children[index].props.children[0]) { child.props.channel = this.getChannelData(child.props.channel.id);
let divider = children[index].props.children[0][i]; let oldType = child.type;
if (divider && divider.props && divider.props.className == BDFDB.disCN.messagespopoutchannelseparator) { child.type = (...args) => {
let channel = BDFDB.ReactUtils.findValue(children[index].props.children[0][parseInt(i)+1], "channel"); let instance = oldType(...args);
if (BDFDB.ChannelUtils.isTextChannel(channel)) { let channelName = BDFDB.ReactUtils.findChild(instance, {props:[["className", BDFDB.disCN.recentmentionschannelname]]});
let [children2, index2] = BDFDB.ReactUtils.findParent(divider, {props:[["className", BDFDB.disCN.messagespopoutchannelname]]}); if (channelName) this.changeChannelColor(channelName, child.props.channel.id);
if (index2 > -1) { return instance;
children2[index2].props.children = "#" + this.getChannelData(channel.id).name; };
this.changeChannelColor(children2[index2], channel.id); child.type.displayName = oldType.displayName;
}
}
}
} }
} }
} }