Add user profile modal data attributes

This commit is contained in:
Samuel Elliott 2018-04-27 15:53:49 +01:00
parent 17575fc6a1
commit 0944c0708f
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
1 changed files with 12 additions and 0 deletions

View File

@ -298,6 +298,7 @@ export class ReactAutoPatcher {
await this.patchGuild(); await this.patchGuild();
await this.patchChannel(); await this.patchChannel();
await this.patchChannelList(); await this.patchChannelList();
await this.patchUserProfileModal();
this.forceUpdate(); this.forceUpdate();
} }
@ -367,6 +368,17 @@ export class ReactAutoPatcher {
}); });
} }
static async patchUserProfileModal() {
this.UserProfileModal = await ReactComponents.getComponent('UserProfileModal', { selector: '.root-2sNHUF' }, Filters.byPrototypeFields(['renderHeader', 'renderBadges']));
this.unpatchUserProfileModal = MonkeyPatch('BD:ReactComponents', this.UserProfileModal.component.prototype).after('render', (component, args, retVal) => {
const { user } = 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';
});
}
static forceUpdate() { static forceUpdate() {
for (const e of document.querySelectorAll('.message, .message-group, .guild, .containerDefault-7RImuF, .channel-members .member-2FrNV0')) { for (const e of document.querySelectorAll('.message, .message-group, .guild, .containerDefault-7RImuF, .channel-members .member-2FrNV0')) {
Reflection(e).forceUpdate(); Reflection(e).forceUpdate();