EditChannels
This commit is contained in:
parent
ad612dfe55
commit
906f3ed6de
|
@ -412,6 +412,7 @@
|
|||
"LazyImageZoomable": {"strings": ["renderLinkComponent", "onCloseImage"]},
|
||||
"ListItemTooltip": {"strings": [".listItemWrapper", "tooltipClassName", "disableWrapper"]},
|
||||
"MemberListItem": {"protos": ["renderOwner", "renderDecorators", "renderPremium"]},
|
||||
"Mention": {"strings": [".iconType", ".color,", "CHANNEL_BROWSER_TITLE"]},
|
||||
"Menu": {"strings": ["\"empty\"", "getItemProps", "isUsingKeyboardNavigation"]},
|
||||
"Message": {"strings": ["childrenMessageContent", "childrenRepliedMessage", "zalgo", ".buttonContainer"]},
|
||||
"MessageAccessories": {"protos": ["renderGiftCodes", "renderEmbeds", "renderActivityInvite"]},
|
||||
|
@ -454,7 +455,8 @@
|
|||
"Reactor": {"strings": ["currentUser cannot be undefined", "reactorDefault"]},
|
||||
"ReactorsComponent": {"strings": ["hasMore", "emoji", "spinnerMore"]},
|
||||
"RecentMentions": {"strings": ["canCloseAllMessages", "RECENT_MENTIONS", "badgeable"]},
|
||||
"RecentsChannelHeader": {"strings": ["\"ArrowRight\"", "gotoChannel:"]},
|
||||
"RecentsChannelHeader": {"strings": [".subtextContainer", ".channelNameSpan", ".channelNameHeader", ".gotoChannel"]},
|
||||
"RichChannelMention": {"strings": ["iconType:", "Messages.DELETED_CHANNEL_PLACEHOLDER"]},
|
||||
"RichUserMention": {"strings": ["hidePersonalInformation", "getUser", "userTooltip"]},
|
||||
"SearchBar": {"strings": [").inputRef", ".containerRef", ".handleOnChange"]},
|
||||
"SearchPopout": {"strings": [".handleHintClick", ".selectedIndex", "token.start"]},
|
||||
|
@ -467,12 +469,16 @@
|
|||
"Spoiler": {"strings": ["revealSpoiler", ".onReveal"]},
|
||||
"SpoilerWarning": {"strings": [".spoilerWarning", ".SPOILER"]},
|
||||
"StandardSidebarView": {"strings": ["standardSidebarView", ".sidebarTheme", "mobileSidebarHeader"]},
|
||||
"SystemMessageThreadCreated": {"strings": ["threadOnClick:", ".SYSTEM_MESSAGE_THREAD_CREATED", "viewThreadsOnClick:"]},
|
||||
"SystemMessageWrapper": {"strings": ["unknown message type", "\"SystemMessage\""]},
|
||||
"TabBar": {"props": ["Types", "Looks", "Item", "Panel"]},
|
||||
"TextChannelEmptyMessage": {"strings": ["MANAGE_CHANNELS", ".BEGINNING_CHANNEL_DESCRIPTION", "topicHook:"]},
|
||||
"Tooltip": {"protos": ["renderTooltip", "setDomElement", "shouldShowTooltip", "toggleShow"]},
|
||||
"TransitionGroup": {"protos": ["performAppear", "performEnter", "performLeave"]},
|
||||
"ThreadCard": {"strings": [".threadId", ".gotoThread", ".container", ".threadName"]},
|
||||
"ThreadEmptyMessage": {"strings": [",{channel:", ".name)", "{channelId:", ".iconWrapper", ".icon}"]},
|
||||
"ThreadMessageAccessories": {"strings": ["threadMetadata", "NO_RECENT_THREAD_MESSAGES", ".Messages.THREAD"]},
|
||||
"ThreadSidebar": {"strings": [".baseChannelId", ".SIDEBAR", ".THREAD_HEADER_BAR"]},
|
||||
"UnavailableGuildsButton": {"strings": [".errorInner", ".guildsError", "Messages.PARTIAL_OUTAGE"]},
|
||||
"UnreadDMs": {"strings": ["getMutablePrivateChannels", "selectedVoiceGuildId", ".selectedVoiceChannelId"]},
|
||||
"UseCopyIdItem": {"strings": ["\"devmode-copy-id\""]},
|
||||
|
@ -2958,6 +2964,8 @@
|
|||
"radiogroup": ["RadioGroup", "item"],
|
||||
"radiogroupinner": ["RadioGroup", "radioBar"],
|
||||
"recentmentionschannelname": ["RecentMentionsHeader", "channelName"],
|
||||
"recentmentionschannelnameheader": ["RecentMentionsHeader", "channelNameHeader"],
|
||||
"recentmentionschannelnamespan": ["RecentMentionsHeader", "channelNameSpan"],
|
||||
"recentmentionsclosebutton": ["RecentMentions", "closeButton"],
|
||||
"recentmentionsdmicon": ["RecentMentionsHeader", "dmIcon"],
|
||||
"recentmentionsguildicon": ["RecentMentionsHeader", "guildIcon"],
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name EditChannels
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 4.4.2
|
||||
* @version 4.4.3
|
||||
* @description Allows you to locally edit Channels
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -83,48 +83,48 @@ module.exports = (_ => {
|
|||
}
|
||||
};
|
||||
|
||||
this.patchedModules = {
|
||||
before: {
|
||||
ChannelTextAreaEditor: "render",
|
||||
TextChannelEmptyMessage: "default",
|
||||
ThreadEmptyMessage: "default",
|
||||
SystemMessageWrapper: "type",
|
||||
AutocompleteChannelResult: "render",
|
||||
GuildSettingsAuditLogEntry: "render",
|
||||
SettingsInvites: "render",
|
||||
HeaderBarContainer: "default",
|
||||
ChannelCategoryItem: "type",
|
||||
ChannelItem: "default",
|
||||
GuildSidebarThreadListEntry: "type",
|
||||
QuickSwitchChannelResult: "render",
|
||||
SearchPopoutComponent: "render",
|
||||
MessageContent: "type"
|
||||
},
|
||||
after: {
|
||||
ThreadMessageAccessories: "default",
|
||||
ThreadCreated: "default",
|
||||
AutocompleteChannelResult: "render",
|
||||
GuildSettingsAuditLogEntry: "render",
|
||||
HeaderBarContainer: "default",
|
||||
ThreadSidebar: "default",
|
||||
ThreadCard: "type",
|
||||
FocusRing: "FocusRing",
|
||||
ChannelItem: "default",
|
||||
GuildSidebarThreadListEntry: "type",
|
||||
DirectMessage: "render",
|
||||
PrivateChannel: "render",
|
||||
QuickSwitchChannelResult: "render",
|
||||
SearchResultsInner: "default",
|
||||
RecentsChannelHeader: "default",
|
||||
RichChannelMention: "ChannelMention"
|
||||
}
|
||||
this.modulePatches = {
|
||||
before: [
|
||||
"AuditLogEntry",
|
||||
"AutocompleteChannelResult",
|
||||
"ChannelsList",
|
||||
"ChannelTextAreaEditor",
|
||||
"ChannelThreadItem",
|
||||
"GuildSettingsInvites",
|
||||
"MessageContent",
|
||||
"QuickSwitchChannelResult",
|
||||
"RecentsChannelHeader",
|
||||
"SearchPopout",
|
||||
"SystemMessageWrapper",
|
||||
"TextChannelEmptyMessage",
|
||||
"ThreadEmptyMessage",
|
||||
"ThreadMessageAccessories"
|
||||
],
|
||||
after: [
|
||||
"AuditLogEntry",
|
||||
"AutocompleteChannelResult",
|
||||
"ChannelItem",
|
||||
"ChannelThreadItem",
|
||||
"DirectMessage",
|
||||
"FocusRingScope",
|
||||
"HeaderBarContainer",
|
||||
"PrivateChannel",
|
||||
"QuickSwitchChannelResult",
|
||||
"RecentsChannelHeader",
|
||||
"RichChannelMention",
|
||||
"SearchResultsInner",
|
||||
"SystemMessageThreadCreated",
|
||||
"ThreadCard",
|
||||
"ThreadMessageAccessories",
|
||||
"ThreadSidebar"
|
||||
]
|
||||
};
|
||||
|
||||
this.patchPriority = 9;
|
||||
|
||||
this.css = `
|
||||
${BDFDB.dotCN.messagespopoutchannelname}:hover > span[style*="color"],
|
||||
${BDFDB.dotCN.recentmentionschannelname}:hover > span[style*="color"],
|
||||
${BDFDB.dotCN.recentmentionschannelname}:hover span[style*="color"],
|
||||
${BDFDB.dotCN.searchresultschannelname}:hover > span[style*="color"] {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
@ -217,9 +217,10 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
onChannelContextMenu (e) {
|
||||
if (e.instance.props.channel && (e.subType == "useChannelDeleteItem" || e.subType == "useChannelLeaveItem")) {
|
||||
if (e.returnvalue.length > 0) e.returnvalue.unshift(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuSeparator, {}));
|
||||
e.returnvalue.unshift(BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||
if (!e.instance.props.channel) return;
|
||||
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: 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, {
|
||||
|
@ -245,57 +246,58 @@ module.exports = (_ => {
|
|||
})
|
||||
]
|
||||
})
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
onThreadContextMenu (e) {
|
||||
this.onChannelContextMenu(e);
|
||||
}
|
||||
|
||||
onGroupDMContextMenu (e) {
|
||||
this.onChannelContextMenu(e);
|
||||
}
|
||||
|
||||
processChannelTextAreaEditor (e) {
|
||||
if (!e.instance.props.disabled && e.instance.props.channel && changedChannels[e.instance.props.channel.id] && (e.instance.props.type == BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL || e.instance.props.type == BDFDB.LibraryComponents.ChannelTextAreaTypes.SIDEBAR) && this.settings.places.chatTextarea) {
|
||||
if (!this.settings.places.chatTextarea || e.instance.props.disabled || !e.instance.props.channel || !changedChannels[e.instance.props.channel.id] || e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.NORMAL_WITH_ACTIVITY && e.instance.props.type != BDFDB.DiscordConstants.ChannelTextAreaTypes.SIDEBAR) return;
|
||||
if (changedChannels[e.instance.props.channel.id].name) e.instance.props.placeholder = BDFDB.LanguageUtils.LanguageStringsFormat("TEXTAREA_PLACEHOLDER", `#${changedChannels[e.instance.props.channel.id].name}`);
|
||||
}
|
||||
}
|
||||
|
||||
processTextChannelEmptyMessage (e) {
|
||||
if (e.instance.props.channel && changedChannels[e.instance.props.channel.id] && this.settings.places.chatWindow) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
if (this.settings.places.chatWindow && e.instance.props.channel && changedChannels[e.instance.props.channel.id]) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
}
|
||||
|
||||
processThreadEmptyMessage (e) {
|
||||
if (e.instance.props.channel && changedChannels[e.instance.props.channel.id] && this.settings.places.chatWindow) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
if (this.settings.places.chatWindow && e.instance.props.channel && changedChannels[e.instance.props.channel.id]) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
}
|
||||
|
||||
processSystemMessageWrapper (e) {
|
||||
if (e.instance.props.channel && changedChannels[e.instance.props.channel.id] && this.settings.places.chatWindow) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
if (this.settings.places.chatWindow && e.instance.props.channel && changedChannels[e.instance.props.channel.id]) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
}
|
||||
|
||||
processThreadCreated (e) {
|
||||
if (e.instance.props.message && e.instance.props.message.messageReference && e.instance.props.message.messageReference.channel_id && changedChannels[e.instance.props.message.messageReference.channel_id] && this.settings.places.chatWindow) {
|
||||
processSystemMessageThreadCreated (e) {
|
||||
if (!this.settings.places.chatWindow || !e.instance.props.message || !e.instance.props.message.messageReference || !e.instance.props.message.messageReference.channel_id || !changedChannels[e.instance.props.message.messageReference.channel_id]) return;
|
||||
let channelName = BDFDB.ObjectUtils.get(e, "returnvalue.props.children.2.props.children.0");
|
||||
if (changedChannels[e.instance.props.message.messageReference.channel_id].name) channelName.props.children = [changedChannels[e.instance.props.message.messageReference.channel_id].name];
|
||||
this.changeChannelColor(channelName, e.instance.props.message.messageReference.channel_id);
|
||||
}
|
||||
}
|
||||
|
||||
processThreadMessageAccessories (e) {
|
||||
if (e.returnvalue.props.channel && changedChannels[e.returnvalue.props.channel.id] && this.settings.places.chatWindow) {
|
||||
e.returnvalue.props.channel = this.getChannelData(e.returnvalue.props.channel.id);
|
||||
let type = e.returnvalue.type;
|
||||
e.returnvalue.type = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let returnValue = type(...args);
|
||||
let channelName = BDFDB.ReactUtils.findChild(returnValue, {props: [["className", BDFDB.disCN.messagesystemname]]});
|
||||
this.changeChannelColor(channelName, e.instance.props.message.messageReference.channel_id);
|
||||
return returnValue;
|
||||
}, "Error in Type Render of ThreadMessageAccessories!", this);
|
||||
if (!this.settings.places.chatWindow || !e.instance.props.channel || !changedChannels[e.instance.props.channel.id]) return;
|
||||
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
else {
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.messagesystemname]]});
|
||||
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id);
|
||||
}
|
||||
}
|
||||
|
||||
processAutocompleteChannelResult (e) {
|
||||
if (e.instance.props.channel && this.settings.places.autocompletes) {
|
||||
if (!this.settings.places.autocompletes || !e.instance.props.channel) return;
|
||||
if (!e.returnvalue) {
|
||||
if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id);
|
||||
e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
}
|
||||
else {
|
||||
if (typeof e.returnvalue.props.children == "function") {
|
||||
else if (typeof e.returnvalue.props.children == "function") {
|
||||
let childrenRender = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let modify = Object.assign({}, e.instance.props, e.instance.state);
|
||||
|
@ -316,46 +318,43 @@ module.exports = (_ => {
|
|||
return iconChild;
|
||||
}, "Error in Type of AutocompleteRowIcon!", this);
|
||||
}
|
||||
let channelName = BDFDB.ReactUtils.findChild(children, {name: "AutocompleteRowHeading"});
|
||||
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify);
|
||||
let channelName = BDFDB.ReactUtils.findChild(children, {name: "AutocompleteRowContentPrimary"});
|
||||
if (channelName) this.changeChannelColor(channelName.props.children, e.instance.props.channel.id, modify);
|
||||
let categoryName = e.instance.props.category && BDFDB.ReactUtils.findChild(children, {name: "AutocompleteRowContentSecondary"});
|
||||
if (categoryName) this.changeChannelColor(categoryName, e.instance.props.category.id, modify);
|
||||
return children;
|
||||
}, "Error in Children Render of AutocompleteChannelResult!", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processGuildSettingsAuditLogEntry (e) {
|
||||
processAuditLogEntry (e) {
|
||||
if (!this.settings.places.auditLog) return;
|
||||
let channel = BDFDB.ObjectUtils.get(e.instance, "props.log.options.channel");
|
||||
if (channel && this.settings.places.auditLog) {
|
||||
if (!channel) return;
|
||||
if (!e.returnvalue) e.instance.props.log.options.channel = this.getChannelData(channel.id);
|
||||
else {
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["children", [["#" + channel.name]]]]});
|
||||
if (channelName) this.changeChannelColor(channelName, channel.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processSettingsInvites (e) {
|
||||
if (BDFDB.ObjectUtils.is(e.instance.props.invites) && this.settings.places.inviteLog) {
|
||||
processGuildSettingsInvites (e) {
|
||||
if (!this.settings.places.inviteLog || !e.instance.props.invites) return;
|
||||
e.instance.props.invites = Object.assign({}, e.instance.props.invites);
|
||||
for (let id in e.instance.props.invites) e.instance.props.invites[id] = new BDFDB.DiscordObjects.Invite(Object.assign({}, e.instance.props.invites[id], {channel: this.getChannelData(e.instance.props.invites[id].channel.id)}));
|
||||
}
|
||||
}
|
||||
|
||||
processHeaderBarContainer (e) {
|
||||
if (!this.settings.places.channelHeader) return;
|
||||
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(e.instance.props.channelId);
|
||||
if (channel && this.settings.places.channelHeader) {
|
||||
if (!channel) return;
|
||||
let thread;
|
||||
if (BDFDB.ChannelUtils.isThread(channel)) {
|
||||
thread = channel;
|
||||
channel = BDFDB.LibraryStores.ChannelStore.getChannel(thread.parent_id);
|
||||
}
|
||||
if (changedChannels[channel.id] || thread && changedChannels[thread.id]) {
|
||||
if (!e.returnvalue) {
|
||||
let channelNames = BDFDB.ReactUtils.findChild(e.instance, {all: true, name: ["Title", "ChannelName"]});
|
||||
if (!changedChannels[channel.id] && !(thread && changedChannels[thread.id])) return;
|
||||
let channelNames = BDFDB.ReactUtils.findChild(e.returnvalue, {all: true, name: ["HeaderBarTitle", "HeaderBarChannelName"]});
|
||||
if (channelNames.length) {
|
||||
if (channelNames[0].props.children) {
|
||||
if (changedChannels[channel.id] && changedChannels[channel.id].name) channelNames[0].props.children = channel.isGroupDM() ? this.getGroupName(channel.id) : this.getChannelData(channel.id).name;
|
||||
|
@ -367,9 +366,7 @@ module.exports = (_ => {
|
|||
this.changeChannelColor(channelNames[1], thread.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
let channelIcons = BDFDB.ReactUtils.findChild(e.instance, {all: true, name: "Icon"});
|
||||
let channelIcons = BDFDB.ReactUtils.findChild(e.returnvalue, {all: true, name: "HeaderBarTitleIcon"});
|
||||
if (channelIcons.length) {
|
||||
if (channelIcons[0].props.icon) {
|
||||
let iconRender = channelIcons[0].props.icon;
|
||||
|
@ -389,18 +386,15 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processThreadSidebar (e) {
|
||||
if (changedChannels[e.instance.props.channelId] && this.settings.places.channelHeader) {
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {name: ["Title", "ChannelName"]});
|
||||
if (!this.settings.places.channelHeader || !changedChannels[e.instance.props.channelId]) return;
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {name: ["HeaderBarTitle", "HeaderBarChannelName"]});
|
||||
if (channelName && channelName.props.children) {
|
||||
if (changedChannels[e.instance.props.channelId].name) channelName.props.children = this.getChannelData(e.instance.props.channelId).name;
|
||||
this.changeChannelColor(channelName, e.instance.props.channelId);
|
||||
}
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "Icon"});
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {name: "HeaderBarTitleIcon"});
|
||||
if (index > -1) {
|
||||
let icon = BDFDB.ReactUtils.createElement(children[index].props.icon, {
|
||||
className: BDFDB.disCN.channelheadericon
|
||||
|
@ -412,20 +406,18 @@ module.exports = (_ => {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processThreadCard (e) {
|
||||
if (changedChannels[e.instance.props.threadId] && this.settings.places.threads) {
|
||||
if (!this.settings.places.threads || !changedChannels[e.instance.props.threadId]) return;
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.threadcardname]]});
|
||||
if (channelName) {
|
||||
if (changedChannels[e.instance.props.threadId].name) channelName.props.children = changedChannels[e.instance.props.threadId].name;
|
||||
this.changeChannelColor(channelName, e.instance.props.threadId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processFocusRing (e) {
|
||||
if (e.returnvalue && e.returnvalue.props.className) {
|
||||
processFocusRingScope (e) {
|
||||
if (!e.returnvalue || !e.returnvalue.props.className) return;
|
||||
let change, hoveredEvents, channelId, nameClass, categoyClass, iconClass, modify = {};
|
||||
if (this.settings.places.channelList && e.returnvalue.props.className.indexOf(BDFDB.disCN.categoryiconvisibility) > -1) {
|
||||
change = true;
|
||||
|
@ -482,37 +474,29 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processChannelCategoryItem (e) {
|
||||
if (e.instance.props.channel && this.settings.places.channelList) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id, true, e.instance.props.channel);
|
||||
processChannelsList (e) {
|
||||
if (!this.settings.places.channelList || !e.instance.props.guildChannels) return;
|
||||
e.instance.props.guildChannels = new e.instance.props.guildChannels.constructor(e.instance.props.guild.id, e.instance.props.guildChannels.communitySection && e.instance.props.guildChannels.communitySection.communityRows || []);
|
||||
let getCategoryFromSection = e.instance.props.guildChannels.getCategoryFromSection.bind(e.instance.props.guildChannels);
|
||||
e.instance.props.guildChannels.getCategoryFromSection = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let returnValue = getCategoryFromSection(...args);
|
||||
if (returnValue && returnValue.record) returnValue.record = this.getChannelData(returnValue.record.id);
|
||||
return returnValue;
|
||||
}, "Error in getCategoryFromSection of ChannelsList!", this);
|
||||
let getChannelFromSectionRow = e.instance.props.guildChannels.getChannelFromSectionRow.bind(e.instance.props.guildChannels);
|
||||
e.instance.props.guildChannels.getChannelFromSectionRow = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let returnValue = getChannelFromSectionRow(...args);
|
||||
if (returnValue.channel && returnValue.category) returnValue = Object.assign({}, returnValue, {
|
||||
channel: Object.assign({}, returnValue.channel, {record: this.getChannelData(returnValue.channel.record.id)}),
|
||||
category: Object.assign({}, returnValue.category, {record: this.getChannelData(returnValue.category.record.id)})
|
||||
});
|
||||
return returnValue;
|
||||
}, "Error in getChannelFromSectionRow of ChannelsList!", this);
|
||||
}
|
||||
|
||||
processChannelItem (e) {
|
||||
if (e.instance.props.channel && this.settings.places.channelList) {
|
||||
if (!e.returnvalue) {
|
||||
e.instance.props.channel = this.getChannelData(e.instance.props.channel.id, true, e.instance.props.channel);
|
||||
let changeColors = (wrapper, props) => {
|
||||
let color = this.chooseColor(this.getChannelDataColor(e.instance.props.channel.id), props);
|
||||
let channelName = wrapper.querySelector(BDFDB.dotCN.channelnameinner);
|
||||
let channelIcon = wrapper.querySelector(BDFDB.dotCN.channelicon);
|
||||
if (channelName && channelName.firstElementChild) channelName.firstElementChild.style.setProperty("color", color);
|
||||
if (channelIcon) {
|
||||
for (let path of channelIcon.querySelectorAll('[path*="rgba("], [path*="rgb("]')) path.setAttribute("path", color);
|
||||
for (let fill of channelIcon.querySelectorAll('[fill*="rgba("], [fill*="rgb("]')) fill.setAttribute("fill", color);
|
||||
}
|
||||
};
|
||||
let onMouseEnter = e.instance.props.onMouseEnter, onMouseLeave = e.instance.props.onMouseLeave;
|
||||
e.instance.props.onMouseEnter = BDFDB.TimeUtils.suppress(event => {
|
||||
changeColors(event.currentTarget, {hovered: true});
|
||||
return (onMouseEnter || (_ => {}))(event);
|
||||
}, "Error in onMouseEnter of ChannelItem!", this);
|
||||
e.instance.props.onMouseLeave = BDFDB.TimeUtils.suppress(event => {
|
||||
changeColors(event.currentTarget, BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected", "hovered"));
|
||||
return (onMouseLeave || (_ => {}))(event);
|
||||
}, "Error in onMouseLeave of ChannelItem!", this);
|
||||
}
|
||||
else {
|
||||
if (!this.settings.places.channelList || !e.instance.props.channel) return;
|
||||
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected", "hovered");
|
||||
let channelName = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["className", BDFDB.disCN.channelnameinner]]});
|
||||
if (channelName) this.changeChannelColor(channelName, e.instance.props.channel.id, modify);
|
||||
|
@ -533,11 +517,9 @@ module.exports = (_ => {
|
|||
}, "Error in Type Render of ChannelItem!", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processGuildSidebarThreadListEntry (e) {
|
||||
if (e.instance.props.thread && this.settings.places.channelList) {
|
||||
processChannelThreadItem (e) {
|
||||
if (!this.settings.places.channelList || !e.instance.props.thread) return;
|
||||
if (!e.returnvalue) e.instance.props.thread = this.getChannelData(e.instance.props.thread.id, true, e.instance.props.thread);
|
||||
else {
|
||||
let modify = BDFDB.ObjectUtils.extract(e.instance.props, "muted", "locked", "selected", "unread", "connected", "hovered");
|
||||
|
@ -545,10 +527,9 @@ module.exports = (_ => {
|
|||
if (channelName) this.changeChannelColor(channelName, e.instance.props.thread.id, modify);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processDirectMessage (e) {
|
||||
if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.recentDms) {
|
||||
if (!this.settings.places.recentDms || !e.instance.props.channel || !e.instance.props.channel.isGroupDM()) return;
|
||||
if (changedChannels[e.instance.props.channel.id] && changedChannels[e.instance.props.channel.id].name) {
|
||||
let tooltip = BDFDB.ReactUtils.findChild(e.returnvalue, {name: "ListItemTooltip"});
|
||||
if (tooltip) tooltip.props.text = this.getGroupName(e.instance.props.channel.id);
|
||||
|
@ -563,36 +544,33 @@ module.exports = (_ => {
|
|||
}, "Error in Avatar Render of DirectMessage!", this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processPrivateChannel (e) {
|
||||
if (e.instance.props.channel && e.instance.props.channel.isGroupDM() && this.settings.places.channelList) {
|
||||
if (!this.settings.places.channelList || !e.instance.props.channel || !e.instance.props.channel.isGroupDM()) return;
|
||||
let wrapper = e.returnvalue && e.returnvalue.props.children && e.returnvalue.props.children.props && typeof e.returnvalue.props.children.props.children == "function" ? e.returnvalue.props.children : e.returnvalue;
|
||||
if (typeof wrapper.props.children == "function") {
|
||||
let process = returnvalue => {
|
||||
const wrapper = returnvalue.props.avatar ? returnvalue : BDFDB.ReactUtils.findChild(returnvalue, {props: ["avatar"]});
|
||||
if (!wrapper) return;
|
||||
if (changedChannels[e.instance.props.channel.id] && changedChannels[e.instance.props.channel.id].name) {
|
||||
wrapper.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(e.instance.props.channel.id)});
|
||||
}
|
||||
this.changeChannelColor(wrapper.props.name, e.instance.props.channel.id, BDFDB.ObjectUtils.extract(Object.assign({}, e.instance.props, e.instance.state), "hovered", "selected", "hasUnreadMessages", "muted"));
|
||||
wrapper.props.name = [wrapper.props.name];
|
||||
if (wrapper.props.avatar) wrapper.props.avatar.props.src = this.getGroupIcon(e.instance.props.channel.id);
|
||||
};
|
||||
let childrenRender = wrapper.props.children;
|
||||
wrapper.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let children = childrenRender(...args);
|
||||
this._processPrivateChannel(e.instance, children);
|
||||
process(children);
|
||||
return children;
|
||||
}, "Error in Children Render of PrivateChannel!", this);
|
||||
}
|
||||
else this._processPrivateChannel(e.instance, wrapper);
|
||||
}
|
||||
}
|
||||
|
||||
_processPrivateChannel (instance, returnvalue) {
|
||||
const wrapper = returnvalue.props.avatar ? returnvalue : BDFDB.ReactUtils.findChild(returnvalue, {props: ["avatar"]});
|
||||
if (!wrapper) return;
|
||||
if (changedChannels[instance.props.channel.id] && changedChannels[instance.props.channel.id].name) {
|
||||
wrapper.props.name = BDFDB.ReactUtils.createElement("span", {children: this.getGroupName(instance.props.channel.id)});
|
||||
}
|
||||
this.changeChannelColor(wrapper.props.name, instance.props.channel.id, {modify: BDFDB.ObjectUtils.extract(Object.assign({}, instance.props, instance.state), "hovered", "selected", "hasUnreadMessages", "muted")});
|
||||
wrapper.props.name = [wrapper.props.name];
|
||||
if (wrapper.props.avatar) wrapper.props.avatar.props.src = this.getGroupIcon(instance.props.channel.id);
|
||||
else process(wrapper);
|
||||
}
|
||||
|
||||
processQuickSwitchChannelResult (e) {
|
||||
if (e.instance.props.channel && this.settings.places.quickSwitcher) {
|
||||
if (!this.settings.places.quickSwitcher || !e.instance.props.channel) return;
|
||||
if (!e.returnvalue) {
|
||||
e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
if (e.instance.props.category) e.instance.props.category = this.getChannelData(e.instance.props.category.id);
|
||||
|
@ -609,16 +587,14 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processSearchPopoutComponent (e) {
|
||||
if (BDFDB.ArrayUtils.is(BDFDB.ObjectUtils.get(e, "instance.props.resultsState.autocompletes")) && this.settings.places.searchPopout) {
|
||||
processSearchPopout (e) {
|
||||
if (!this.settings.places.searchPopout || !BDFDB.ArrayUtils.is(BDFDB.ObjectUtils.get(e, "instance.props.resultsState.autocompletes"))) return;
|
||||
for (let autocomplete of e.instance.props.resultsState.autocompletes) if (autocomplete && BDFDB.ArrayUtils.is(autocomplete.results)) for (let result of autocomplete.results) if (result.channel) result.channel = this.getChannelData(result.channel.id);
|
||||
}
|
||||
}
|
||||
|
||||
processSearchResultsInner (e) {
|
||||
if (this.settings.places.searchResults) {
|
||||
if (!this.settings.places.searchResults) return;
|
||||
let results = BDFDB.ReactUtils.findChild(e.returnvalue, {props: [["id", "search-results"]]});
|
||||
if (results && BDFDB.ArrayUtils.is(results.props.children)) for (let group of results.props.children) {
|
||||
let channelId = (BDFDB.ObjectUtils.get(group, "props.children.key") || "").split("-")[0];
|
||||
|
@ -629,35 +605,30 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processRecentsChannelHeader (e) {
|
||||
if (this.settings.places.recentMentions && BDFDB.ArrayUtils.is(e.returnvalue.props.children)) {
|
||||
for (let child of e.returnvalue.props.children) if (child && child.props && child.props.channel && child.type.displayName == "ChannelName") {
|
||||
child.props.channel = this.getChannelData(child.props.channel.id);
|
||||
let oldType = child.type;
|
||||
child.type = (...args) => {
|
||||
let instance = oldType(...args);
|
||||
let channelName = BDFDB.ReactUtils.findChild(instance, {props: [["className", BDFDB.disCN.recentmentionschannelname]]});
|
||||
if (channelName) this.changeChannelColor(channelName, child.props.channel.id);
|
||||
return instance;
|
||||
};
|
||||
child.type.displayName = oldType.displayName;
|
||||
if (!this.settings.places.recentMentions || !e.instance.props.channel) return;
|
||||
if (!e.returnvalue) e.instance.props.channel = this.getChannelData(e.instance.props.channel.id);
|
||||
else {
|
||||
let [children, index] = BDFDB.ReactUtils.findParent(e.returnvalue, {props: [["className", BDFDB.disCN.recentmentionschannelnamespan]]});
|
||||
if (index > -1) {
|
||||
this.changeChannelColor(children[index], e.instance.props.channel.id);
|
||||
let icon = index > 0 && children[index-1];
|
||||
if (icon && icon.props && icon.props.width) this.changeChannelIconColor(icon, e.instance.props.channel.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processMessageContent (e) {
|
||||
if (BDFDB.ArrayUtils.is(e.instance.props.content) && this.settings.places.mentions) for (let ele of e.instance.props.content) {
|
||||
if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && ele.type.displayName == "Tooltip" && typeof ele.props.children == "function") {
|
||||
if (!this.settings.places.mentions || !BDFDB.ArrayUtils.is(e.instance.props.content)) return;
|
||||
for (let ele of e.instance.props.content) if (BDFDB.ReactUtils.isValidElement(ele) && ele.type && ele.type.prototype && ele.type.prototype.renderTooltip && typeof ele.props.children == "function") {
|
||||
let children = ele.props.children({});
|
||||
if (children && children.type.displayName == "Mention") {
|
||||
const checkChild = label => {
|
||||
if (label[0] != "#") return;
|
||||
let channelName = label.slice(1);
|
||||
if (!children || !children.props || !children.props.iconType || !children.props.className || children.props.className.indexOf("channelMention") != 0) return;
|
||||
const checkChild = channelName => {
|
||||
let guildId = BDFDB.LibraryStores.SelectedGuildStore.getGuildId();
|
||||
let channels = guildId && [].concat(BDFDB.LibraryStores.GuildChannelStore.getChannels(guildId).SELECTABLE, Object.keys(BDFDB.LibraryStores.ActiveThreadsStore.getThreadsForGuild(guildId)).map(id => ({channel: BDFDB.LibraryStores.ChannelStore.getChannel(id)})));
|
||||
if (BDFDB.ArrayUtils.is(channels)) for (let channelObj of channels) {
|
||||
if (!BDFDB.ArrayUtils.is(channels)) return;
|
||||
for (let channelObj of channels) {
|
||||
if (channelName == channelObj.channel.name) {
|
||||
let category = BDFDB.LibraryStores.ChannelStore.getChannel(channelObj.channel.parent_id);
|
||||
if (!category || category && ele.props.text == category.name) {
|
||||
|
@ -669,11 +640,11 @@ module.exports = (_ => {
|
|||
let color = this.getChannelDataColor(channelObj.channel.id);
|
||||
if (name || color) {
|
||||
let renderChildren = ele.props.children;
|
||||
ele.props.children = (...args) => {
|
||||
let children = renderChildren(...args);
|
||||
this.changeMention(children, {name, color});
|
||||
return children;
|
||||
}
|
||||
ele.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
||||
let renderedChildren = renderChildren(...args);
|
||||
this.changeMention(renderedChildren, {name, color});
|
||||
return renderedChildren;
|
||||
}, "Error in Children Render of ChannelMention in MessageContent!", this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -687,14 +658,12 @@ module.exports = (_ => {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
processRichChannelMention (e) {
|
||||
if (e.instance.props.id && this.settings.places.mentions) {
|
||||
if (!this.settings.places.mentions || !e.instance.props.id) return;
|
||||
let name = (changedChannels[e.instance.props.id] || {}).name;
|
||||
let color = this.getChannelDataColor(e.instance.props.id);
|
||||
if (name || color) {
|
||||
if (!name && !color) return;
|
||||
if (typeof e.returnvalue.props.children == "function") {
|
||||
let renderChildren = e.returnvalue.props.children;
|
||||
e.returnvalue.props.children = BDFDB.TimeUtils.suppress((...args) => {
|
||||
|
@ -705,6 +674,14 @@ module.exports = (_ => {
|
|||
}
|
||||
else this.changeMention(e.returnvalue, {name, color});
|
||||
}
|
||||
|
||||
changeAppTitle () {
|
||||
if (!this.settings.places.appTitle) return;
|
||||
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
|
||||
let title = document.head.querySelector("title");
|
||||
if (title && channel && (document.location.href || "").indexOf(channel.id) > -1 && changedChannels[channel.id] && changedChannels[channel.id].name) {
|
||||
if (channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id));
|
||||
else BDFDB.DOMUtils.setText(title, (BDFDB.ChannelUtils.isTextChannel(channel) ? "#" : "") + this.getChannelData(channel.id).name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -720,27 +697,20 @@ module.exports = (_ => {
|
|||
}
|
||||
else changeMentionName(child[i]);
|
||||
}
|
||||
else if (child.props && typeof child.props.children == "string" && child.props.children[0] == "#") child.props.children = "#" + data.name;
|
||||
else if (child.props && BDFDB.ArrayUtils.is(child.props.children)) changeMentionName(child.props.children);
|
||||
else if (child.props) {
|
||||
if (child.props.iconType && typeof child.props.children == "string") child.props.children = data.name;
|
||||
else if (child.props.iconType && BDFDB.ArrayUtils.is(child.props.children) && child.props.children.length == 1) child.props.children = [data.name];
|
||||
else if (typeof child.props.children == "string" && child.props.children[0] == "#") child.props.children = "#" + data.name;
|
||||
else if (BDFDB.ArrayUtils.is(child.props.children)) changeMentionName(child.props.children);
|
||||
}
|
||||
};
|
||||
changeMentionName(mention);
|
||||
}
|
||||
if (data.color) mention.props.color = BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(data.color) ? data.color[0] : data.color, "INT");
|
||||
}
|
||||
|
||||
changeAppTitle () {
|
||||
if (this.settings.places.appTitle) {
|
||||
let channel = BDFDB.LibraryStores.ChannelStore.getChannel(BDFDB.LibraryStores.SelectedChannelStore.getChannelId());
|
||||
let title = document.head.querySelector("title");
|
||||
if (title && channel && (document.location.href || "").indexOf(channel.id) > -1 && changedChannels[channel.id] && changedChannels[channel.id].name) {
|
||||
if (channel.isGroupDM()) BDFDB.DOMUtils.setText(title, this.getGroupName(channel.id));
|
||||
else BDFDB.DOMUtils.setText(title, (BDFDB.ChannelUtils.isTextChannel(channel) ? "#" : "") + this.getChannelData(channel.id).name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeChannelColor (child, channelId, modify) {
|
||||
if (BDFDB.ReactUtils.isValidElement(child)) {
|
||||
if (!BDFDB.ReactUtils.isValidElement(child)) return;
|
||||
let color = this.getChannelDataColor(channelId);
|
||||
if (color) {
|
||||
color = modify ? this.chooseColor(color, modify) : BDFDB.ColorUtils.convert(color, "RGBA");
|
||||
|
@ -756,13 +726,13 @@ module.exports = (_ => {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeChannelIconColor (child, channelId, modify) {
|
||||
if (!this.settings.general.changeChannelIcon) return;
|
||||
let color = child && this.getChannelDataColor(channelId);
|
||||
if (color && this.settings.general.changeChannelIcon) {
|
||||
if (!color) return;
|
||||
color = modify ? this.chooseColor(BDFDB.ObjectUtils.is(color) ? color[0] : color, modify) : BDFDB.ColorUtils.convert(BDFDB.ObjectUtils.is(color) ? color[0] : color, "RGBA");
|
||||
if (color) {
|
||||
if (!color) return;
|
||||
child.props.foreground = null;
|
||||
child.props.color = color || "currentColor";
|
||||
child.props.children = [child.props.children].flat(10).filter(n => n);
|
||||
|
@ -771,11 +741,9 @@ module.exports = (_ => {
|
|||
if (c && c.props && c.props.path == "currentColor") c.props.path = color || "currentColor";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
chooseColor (color, config) {
|
||||
if (color) {
|
||||
if (!color) return null;
|
||||
if (BDFDB.ObjectUtils.is(config)) {
|
||||
if (config.focused || config.hovered || config.selected || config.connected) color = BDFDB.ColorUtils.change(color, 0.5);
|
||||
else if (config.muted || config.locked) color = BDFDB.ColorUtils.change(color, -0.5);
|
||||
|
@ -783,8 +751,6 @@ module.exports = (_ => {
|
|||
}
|
||||
return BDFDB.ColorUtils.convert(color, "RGBA");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
getChannelDataColor (channelId) {
|
||||
if (changedChannels[channelId] && changedChannels[channelId].color) return changedChannels[channelId].color;
|
||||
|
|
Loading…
Reference in New Issue