fix User Profile modal attributes

pull/67/head
dperolio 3 years ago
parent e08379343c
commit e1d4f3603c
No known key found for this signature in database
GPG Key ID: 3E9BBAA710D3DDCE

@ -4,20 +4,21 @@
* @memberof Builtin.Attributes.Components.Modals
*/
import { getModuleByDisplayName } from '@vizality/webpack';
import { getModule } from '@vizality/webpack';
import { patch, unpatch } from '@vizality/patcher';
import { findInTree } from '@vizality/util/react';
export const labels = [ 'Components', 'Modals', 'User' ];
export default builtin => {
const UserProfile = getModuleByDisplayName('UserProfile');
patch('vz-attributes-modal-user', UserProfile?.prototype, 'render', (_, res) => {
const UserProfile = getModule(m => m.default?.displayName === 'UserProfileModal');
patch('vz-attributes-modal-user', UserProfile, 'default', ([ props ], res) => {
try {
res.ref = elem => {
if (elem?._reactInternalFiber) {
const container = findInTree(elem._reactInternalFiber.return, el => el.stateNode?.setAttribute, { walkable: [ 'return' ] });
container?.stateNode?.children[0]?.setAttribute('vz-user-id', res.props?.user?.id);
container?.stateNode?.children[0]?.setAttribute('vz-user-id', props?.user?.id);
container?.stateNode?.children[0]?.setAttribute('vz-guild-id', props?.guildId);
container?.stateNode?.parentElement?.setAttribute('vz-modal', 'user');
}
};

Loading…
Cancel
Save