From 3c976a9483ce90ebf3dcce018a7da2e8099aadb2 Mon Sep 17 00:00:00 2001 From: Zack Rauen Date: Fri, 4 Feb 2022 15:56:40 -0500 Subject: [PATCH] Fix guild component errors --- renderer/src/builtins/general/publicservers.js | 8 +++++--- renderer/src/modules/componentpatcher.js | 12 +++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/renderer/src/builtins/general/publicservers.js b/renderer/src/builtins/general/publicservers.js index a9f60d20..a52b1262 100644 --- a/renderer/src/builtins/general/publicservers.js +++ b/renderer/src/builtins/general/publicservers.js @@ -10,10 +10,12 @@ export default new class PublicServers extends Builtin { get id() {return "publicServers";} enabled() { - // const GuildList = WebpackModules.find(m => m.type && m.type.toString().includes("guildsnav")); - // if (!GuildList) this.warn("Can't find GuildList component"); - // this.guildPatch = this.after(GuildList, "type", () => {this._appendButton();}); this._appendButton(); + const ListNavigators = WebpackModules.getByProps("ListNavigatorProvider"); + this.after(ListNavigators, "ListNavigatorProvider", (_, __, returnValue) => { + if (returnValue.props.value.id !== "guildsnav") return; + this._appendButton(); + }); } disabled() { diff --git a/renderer/src/modules/componentpatcher.js b/renderer/src/modules/componentpatcher.js index e01c9ac3..b94171ff 100644 --- a/renderer/src/modules/componentpatcher.js +++ b/renderer/src/modules/componentpatcher.js @@ -9,7 +9,6 @@ import Logger from "common/logger"; const React = DiscordModules.React; const Tooltip = WebpackModules.getByDisplayName("Tooltip"); -const MutedStore = WebpackModules.getByProps("isMuted"); const Anchor = WebpackModules.getByDisplayName("Anchor"); const Developers = [ @@ -77,16 +76,10 @@ export default new class ComponentPatcher { patchGuildListItems() { if (this.guildListItemsPatch) return; const ListNavigators = WebpackModules.getByProps("ListNavigatorProvider"); - const GuildComponent = WebpackModules.find(m => m.type && m.type.toString().includes("guildNode") && !m.type.toString().includes("Pending")); + const GuildComponent = WebpackModules.find(m => m.type && m.type.toString().includes("guildNode") && m.type.toString().includes("treeitem")); if (!GuildComponent || typeof(GuildComponent.type) !== "function") return this.warn("Failed to get Guild component."); if (!ListNavigators || typeof(ListNavigators.ListNavigatorProvider) !== "function") return this.warn("Failed to get ListNavigatorProvider component."); - const isGuildMuted = function (guildId) { - if (!MutedStore || typeof(MutedStore.isMuted) !== "function") return false; - - return MutedStore.isMuted(guildId); - }; - this.guildListItemsPatch = Patcher.after("ComponentPatcher", GuildComponent, "type", (_, [props], returnValue) => { if (!returnValue || !returnValue.props) return; @@ -101,10 +94,11 @@ export default new class ComponentPatcher { if (props.unavailable) returnValue.props.className += " bd-unavailable"; if (props.mediaState.screenshare) returnValue.props.className += " bd-screenshare"; if (props.mediaState.liveStage) returnValue.props.className += " bd-live-stage"; - if (isGuildMuted(props.guild.id)) returnValue.props.className += " bd-muted"; + if (props.muted) returnValue.props.className += " bd-muted"; } catch (err) { Logger.error("ComponentPatcher:Guilds", `Error inside BDGuild:`, err); + this.guildListItemsPatch(); } });