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 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;
|
const originalType = messageContent.type.type;
|
||||||
if (originalType.__originalMethod) return; // Don't patch again
|
if (originalType.__originalMethod) return; // Don't patch again
|
||||||
messageContent.type.type = function(childProps) {
|
const self = this;
|
||||||
|
messageContent.type.type = function (childProps) {
|
||||||
const returnValue = originalType(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};
|
returnValue.props.style = {color: roleColor};
|
||||||
return returnValue;
|
return returnValue;
|
||||||
};
|
};
|
||||||
|
@ -38,9 +39,17 @@ 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() {
|
removeColoredText() {
|
||||||
document.querySelectorAll(".markup-2BOw-j").forEach(elem => {
|
document.querySelectorAll(".markup-2BOw-j").forEach(elem => {
|
||||||
elem.style.setProperty("color", "");
|
elem.style.setProperty("color", "");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default Utilities.memoizeObject({
|
||||||
get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");},
|
get GuildPermissions() {return WebpackModules.getByProps("getGuildPermissions");},
|
||||||
|
|
||||||
/* Channel Store & Actions */
|
/* Channel Store & Actions */
|
||||||
get ChannelStore() {return WebpackModules.getByProps("getChannels", "getDMFromUserId");},
|
get ChannelStore() {return WebpackModules.getByProps("getChannel", "getDMFromUserId");},
|
||||||
get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");},
|
get SelectedChannelStore() {return WebpackModules.getByProps("getLastSelectedChannelId");},
|
||||||
get ChannelActions() {return WebpackModules.getByProps("selectChannel");},
|
get ChannelActions() {return WebpackModules.getByProps("selectChannel");},
|
||||||
get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");},
|
get PrivateChannelActions() {return WebpackModules.getByProps("openPrivateChannel");},
|
||||||
|
@ -153,4 +153,4 @@ export default Utilities.memoizeObject({
|
||||||
},
|
},
|
||||||
|
|
||||||
get LayerStack() {return WebpackModules.getByProps("pushLayer");}
|
get LayerStack() {return WebpackModules.getByProps("pushLayer");}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue