From 50ae555c21d309c9beb72d2daaf4679d1fbf54cb Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 24 Aug 2019 21:51:37 +0100 Subject: [PATCH] Fix member list profile badges --- client/src/modules/reactcomponents.js | 2 +- client/src/ui/profilebadges.js | 32 +++++++++++++-------------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index 857a8506..a4181af4 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -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}); } diff --git a/client/src/ui/profilebadges.js b/client/src/ui/profilebadges.js index 31831371..a7cc6647 100644 --- a/client/src/ui/profilebadges.js +++ b/client/src/ui/profilebadges.js @@ -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