Add user popout data attributes

This commit is contained in:
Samuel Elliott 2018-04-27 19:02:35 +01:00
parent d42e8f66ca
commit 36d7554b46
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
1 changed files with 16 additions and 0 deletions

View File

@ -299,6 +299,7 @@ export class ReactAutoPatcher {
await this.patchChannel();
await this.patchChannelList();
await this.patchUserProfileModal();
await this.patchUserPopout();
this.forceUpdate();
}
@ -379,6 +380,21 @@ export class ReactAutoPatcher {
});
}
static async patchUserPopout() {
this.UserProfileModal = await ReactComponents.getComponent('UserPopout', { selector: '.userPopout-11hFKo' });
this.unpatchUserProfileModal = MonkeyPatch('BD:ReactComponents', this.UserProfileModal.component.prototype).after('render', (component, args, retVal) => {
const { user, guild, guildMember } = component.props;
if (!user) return;
retVal.props['data-user-id'] = user.id;
if (user.bot) retVal.props.className += ' bd-isBot';
if (user.id === DiscordApi.currentUser.id) retVal.props.className += ' bd-isCurrentUser';
if (guild) retVal.props['data-guild-id'] = guild.id;
if (guild && user.id === guild.ownerId) retVal.props.className += ' bd-isGuildOwner';
if (guild && guildMember) retVal.props.className += ' bd-isGuildMember';
if (guildMember && guildMember.roles.length) retVal.props.className += ' bd-hasRoles';
});
}
static forceUpdate() {
for (const e of document.querySelectorAll('.message, .message-group, .guild, .containerDefault-7RImuF, .channel-members .member-2FrNV0')) {
Reflection(e).forceUpdate();