Fixes Colored Text for development branch (#531)
* Fix colored text for development branch too. * Fix ChannelStore
This commit is contained in:
parent
1bb613942f
commit
99270038b3
|
@ -1,5 +1,5 @@
|
|||
import Builtin from "../../structs/builtin";
|
||||
import {WebpackModules} from "modules";
|
||||
import {WebpackModules, DiscordModules} from "modules";
|
||||
|
||||
|
||||
|
||||
|
@ -26,9 +26,10 @@ export default new class ColoredText extends Builtin {
|
|||
|
||||
const originalType = messageContent.type.type;
|
||||
if (originalType.__originalMethod) return; // Don't patch again
|
||||
const self = this;
|
||||
messageContent.type.type = function (childProps) {
|
||||
const returnValue = originalType(childProps);
|
||||
const roleColor = childProps.message.colorString || "";
|
||||
const roleColor = self.getRoleColor(childProps.message.channel_id, childProps.message.author.id) || "";
|
||||
returnValue.props.style = {color: roleColor};
|
||||
return returnValue;
|
||||
};
|
||||
|
@ -38,6 +39,14 @@ export default new class ColoredText extends Builtin {
|
|||
});
|
||||
}
|
||||
|
||||
getRoleColor(channelId, memberId) {
|
||||
const channel = DiscordModules.ChannelStore.getChannel(channelId);
|
||||
if (!channel) return "";
|
||||
const member = DiscordModules.GuildMemberStore.getMember(channel.guild_id, memberId);
|
||||
if (!member) return "";
|
||||
return member.colorString;
|
||||
}
|
||||
|
||||
removeColoredText() {
|
||||
document.querySelectorAll(".markup-2BOw-j").forEach(elem => {
|
||||
elem.style.setProperty("color", "");
|
||||
|
|
|
@ -28,7 +28,7 @@ export default Utilities.memoizeObject({
|
|||
get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");},
|
||||
|
||||
/* Channel Store & Actions */
|
||||
get ChannelStore() {return WebpackModules.getByProps("getChannels", "getDMFromUserId");},
|
||||
get ChannelStore() {return WebpackModules.getByProps("getChannel", "getDMFromUserId");},
|
||||
get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");},
|
||||
get ChannelActions() {return WebpackModules.getByProps("selectChannel");},
|
||||
get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");},
|
||||
|
|
Loading…
Reference in New Issue