add guild, channel and user data attributes

This commit is contained in:
Jiiks 2018-03-17 15:23:21 -03:00
parent ffea5bd3ae
commit 8740c286a0
1 changed files with 33 additions and 0 deletions

View File

@ -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;
});
}
}