Merge pull request #175 from JsSucks/data-attributes
add guild, channel and user data attributes
This commit is contained in:
commit
cf2b3485ad
|
@ -275,6 +275,9 @@ export class ReactAutoPatcher {
|
||||||
this.patchMessage();
|
this.patchMessage();
|
||||||
this.patchMessageGroup();
|
this.patchMessageGroup();
|
||||||
this.patchChannelMember();
|
this.patchChannelMember();
|
||||||
|
this.patchGuild();
|
||||||
|
this.patchChannel();
|
||||||
|
this.patchChannelList();
|
||||||
}
|
}
|
||||||
|
|
||||||
static async patchMessage() {
|
static async patchMessage() {
|
||||||
|
@ -311,4 +314,34 @@ export class ReactAutoPatcher {
|
||||||
retVal.props['data-user-id'] = user.id;
|
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;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue