From 5b419cb8ab77e61fcba3c71654f7f88d32f70dc0 Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Wed, 1 Aug 2018 20:41:46 +0100 Subject: [PATCH] Use ReactComponent.forceUpdateAll to rerender components after patching them --- client/src/modules/reactcomponents.js | 24 ++++++------------------ client/src/ui/profilebadges.js | 1 + 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/client/src/modules/reactcomponents.js b/client/src/modules/reactcomponents.js index c0f483ec..30560eb7 100644 --- a/client/src/modules/reactcomponents.js +++ b/client/src/modules/reactcomponents.js @@ -360,9 +360,7 @@ export class ReactAutoPatcher { if (dapiMessage.guild && dapiMessage.guild.isMember(author.id)) retVal.props.className += ' bd-isGuildMember'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.MessageGroup.forceUpdateAll(); } static async patchChannelMember() { @@ -378,9 +376,7 @@ export class ReactAutoPatcher { if (component.props.isOwner) retVal.props.className += ' bd-isGuildOwner'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.ChannelMember.forceUpdateAll(); } static async patchGuild() { @@ -411,9 +407,7 @@ export class ReactAutoPatcher { if (channel.type === 3) retVal.props.className += ' bd-isGroupChannel'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.Channel.forceUpdateAll(); } static async patchChannelList() { @@ -430,9 +424,7 @@ export class ReactAutoPatcher { if (channel.type === 3) retVal.props.className += ' bd-isGroupChannel'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.GuildChannel.forceUpdateAll(); } static async patchUserProfileModal() { @@ -447,9 +439,7 @@ export class ReactAutoPatcher { if (user.id === DiscordApi.currentUser.id) retVal.props.className += ' bd-isCurrentUser'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.UserProfileModal.forceUpdateAll(); } static async patchUserPopout() { @@ -468,8 +458,6 @@ export class ReactAutoPatcher { if (guildMember && guildMember.roles.length) retVal.props.className += ' bd-hasRoles'; }); - for (const e of document.querySelectorAll(selector)) { - Reflection(e).forceUpdate(); - } + this.UserPopout.forceUpdateAll(); } } diff --git a/client/src/ui/profilebadges.js b/client/src/ui/profilebadges.js index 48616a76..82df695e 100644 --- a/client/src/ui/profilebadges.js +++ b/client/src/ui/profilebadges.js @@ -54,6 +54,7 @@ export default class extends Module { }); // Rerender all messages + Message.forceUpdateAll(); } /**