Fix member list profile badges

This commit is contained in:
Samuel Elliott 2019-08-24 21:51:37 +01:00
parent 3022646579
commit 50ae555c21
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 16 additions and 18 deletions

View File

@ -468,7 +468,7 @@ export class ReactAutoPatcher {
}
static async patchNameTag() {
const { selector } = Reflection.resolve('nameTag', 'username', 'discriminator', 'discriminatorWithMobileIndicator');
const { selector } = Reflection.resolve('nameTag', 'username', 'discriminator', 'bot');
this.NameTag = await ReactComponents.getComponent('NameTag', {selector});
}

View File

@ -89,26 +89,24 @@ export default class extends Module {
const NameTag = await ReactComponents.getComponent('NameTag');
this.PatchedNameTag = class extends NameTag.component {
render() {
const retVal = NameTag.component.prototype.render.apply(this, arguments);
try {
if (!retVal.props || !retVal.props.children) return retVal;
this.PatchedNameTag = function (props) {
const retVal = NameTag.component.apply(this, arguments);
try {
if (!retVal.props || !retVal.props.children) return retVal;
const user = ReactHelpers.findProp(this, 'user');
if (!user) return retVal;
const contributor = contributors.find(c => c.id === user.id);
if (!contributor) return retVal;
const user = ReactHelpers.findProp(props, 'user');
if (!user) return retVal;
const contributor = contributors.find(c => c.id === user.id);
if (!contributor) return retVal;
retVal.props.children.splice(1, 0, VueInjector.createReactElement(BdBadge, {
contributor,
type: 'nametag'
}));
} catch (err) {
Logger.err('ProfileBadges', ['Error thrown while rendering a NameTag', err]);
}
return retVal;
retVal.props.children.splice(1, 0, VueInjector.createReactElement(BdBadge, {
contributor,
type: 'nametag'
}));
} catch (err) {
Logger.err('ProfileBadges', ['Error thrown while rendering a NameTag', err]);
}
return retVal;
};
// Rerender all channel members