mirror of https://github.com/vizality/vizality
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.2 KiB
38 lines
1.2 KiB
/**
|
|
* Applies attributes to members on the members sidebar.
|
|
* @module Member
|
|
* @memberof Builtin.Attributes.Misc
|
|
*/
|
|
|
|
import { getModule } from '@vizality/webpack';
|
|
import { patch, unpatch } from '@vizality/patcher';
|
|
|
|
export const labels = [ 'Members', 'Member' ];
|
|
|
|
export default builtin => {
|
|
const MemberListItem = getModule([ 'AVATAR_DECORATION_PADDING' ])
|
|
patch('vz-attributes-members-member', MemberListItem?.default, 'type', (_, res) => {
|
|
try {
|
|
if (!res || !res?.props?.user) return;
|
|
const { user, isOwner, activities } = res.props;
|
|
if (!user) return;
|
|
|
|
const old = res.type.prototype.render
|
|
res.type.prototype.render = function() {
|
|
const res = old.apply(this, arguments)
|
|
|
|
res.props['vz-user-id'] = user.id;
|
|
res.props['vz-activity'] = Boolean(activities?.some(activity => activity.type !== 4)) && '';
|
|
res.props['vz-self'] = Boolean(user.email) && '';
|
|
res.props['vz-bot'] = Boolean(user.bot) && '';
|
|
res.props['vz-owner'] = Boolean(isOwner) && '';
|
|
|
|
return res
|
|
}
|
|
} catch (err) {
|
|
return builtin.error(builtin._labels.concat(labels), err);
|
|
}
|
|
});
|
|
return () => unpatch('vz-attributes-members-member');
|
|
};
|