From 8740c286a0135e77f7d7f73c8938ecb11a9755e4 Mon Sep 17 00:00:00 2001 From: Jiiks Date: Sat, 17 Mar 2018 15:23:21 -0300 Subject: [PATCH] add guild, channel and user data attributes --- client/src/modules/reactcomponents.js | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index e7db20b2..58bfb643 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -275,6 +275,9 @@ export class ReactAutoPatcher { this.patchMessage(); this.patchMessageGroup(); this.patchChannelMember(); + this.patchGuild(); + this.patchChannel(); + this.patchChannelList(); } static async patchMessage() { @@ -311,4 +314,34 @@ export class ReactAutoPatcher { retVal.props['data-user-id'] = user.id; }); } + + static async patchGuild() { + this.Guild = await ReactComponents.getComponent('Guild'); + this.unpatchGuild = MonkeyPatch('BD:ReactComponents', this.Guild.component.prototype).after('render', (component, args, retVal) => { + const { guild } = component.props; + if (!guild) return; + retVal.props['data-guild-id'] = guild.id; + retVal.props['data-guild-name'] = guild.name; + }); + } + + static async patchChannel() { + this.Channel = await ReactComponents.getComponent('Channel'); + this.unpatchChannel = MonkeyPatch('BD:ReactComponents', this.Channel.component.prototype).after('render', (component, args, retVal) => { + const channel = component.props.channel || component.state.channel; + if (!channel) return; + retVal.props['data-channel-id'] = channel.id; + retVal.props['data-channel-name'] = channel.name; + }); + } + + static async patchChannelList() { + this.GuildChannel = await ReactComponents.getComponent('GuildChannel', { selector: '.containerDefault-7RImuF' }); + this.unpatchGuildChannel = MonkeyPatch('BD:ReactComponents', this.GuildChannel.component.prototype).after('render', (component, args, retVal) => { + const { channel } = component.props; + if (!channel) return; + retVal.props['data-channel-id'] = channel.id; + retVal.props['data-channel-name'] = channel.name; + }); + } }