Merge pull request #175 from JsSucks/data-attributes

add guild, channel and user data attributes
This commit is contained in:
Alexei Stukov 2018-03-17 15:43:15 -03:00 committed by GitHub
commit cf2b3485ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;
});
}
}