From 37ed3f2e3f3f1c12b609274580daf879ecbfe520 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Mon, 6 Nov 2023 15:38:01 +0100 Subject: [PATCH] Update ServerHider.plugin.js --- Plugins/ServerHider/ServerHider.plugin.js | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Plugins/ServerHider/ServerHider.plugin.js b/Plugins/ServerHider/ServerHider.plugin.js index 3a907a9e99..b5ef6eba5e 100644 --- a/Plugins/ServerHider/ServerHider.plugin.js +++ b/Plugins/ServerHider/ServerHider.plugin.js @@ -2,7 +2,7 @@ * @name ServerHider * @author DevilBro * @authorId 278543574059057154 - * @version 6.2.8 + * @version 6.2.9 * @description Allows you to hide certain Servers in your Server List * @invite Jx3TjNS * @donate https://www.paypal.me/MircoWittrien @@ -67,6 +67,9 @@ module.exports = (_ => { }; this.modulePatches = { + before: [ + "QuickSwitcher" + ], after: [ "GuildsBar" ] @@ -80,6 +83,15 @@ module.exports = (_ => { if (e.methodArguments[0].type == "STREAMER_MODE_UPDATE") BDFDB.DiscordUtils.rerenderAll(true); }}); + BDFDB.PatchUtils.patch(this, BDFDB.LibraryModules.HistoryUtils, "transitionTo", {instead: e => { + if (!e.methodArguments || this.settings.general.onlyHideInStream && !BDFDB.LibraryStores.StreamerModeStore.enabled) return e.callOriginalMethod(); + if (typeof e.methodArguments[0] == "string" && e.methodArguments[0].startsWith("/channels/")) { + let guildId = (e.methodArguments[0].split("/channels/")[1] || e.methodArguments[0].split("/channels/")[1]).split("/")[0]; + if (guildId && ((hiddenEles.servers || []).includes(guildId) || (hiddenEles.folders || []).includes((BDFDB.GuildUtils.getFolder(guildId) || {}).folderId))) return; + } + return e.callOriginalMethod(); + }}); + BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.SortedGuildStore, "getGuildFolderById", {after: e => { let hiddenGuildIds = hiddenEles.servers || []; if (e.returnValue && hiddenGuildIds.length) { @@ -93,7 +105,7 @@ module.exports = (_ => { BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.GuildReadStateStore, "getMutableGuildStates", {after: e => { if (!e.returnValue || this.settings.general.onlyHideInStream && !BDFDB.LibraryStores.StreamerModeStore.enabled) return; let hiddenGuildIds = hiddenEles && hiddenEles.servers || []; - if (hiddenGuildIds.length) for (let id in e.returnValue) if (hiddenGuildIds.includes(id)) e.returnValue[id] = Object.assign({}, e.returnValue[id], {mentionCount: 0, mentionCounts: {}}); + if (hiddenGuildIds.length) for (let id in e.returnValue) if (hiddenGuildIds.includes(id)) e.returnValue[id] = Object.assign({}, e.returnValue[id], {ncMentionCount: 0, mentionCount: 0, mentionCounts: {}}); }}); BDFDB.DiscordUtils.rerenderAll(); @@ -188,6 +200,16 @@ module.exports = (_ => { } } + processQuickSwitcher (e) { + if (this.settings.general.onlyHideInStream && !BDFDB.LibraryStores.StreamerModeStore.enabled) return; + e.instance.props.results = [].concat(e.instance.props.results).filter(n => { + if (!n) return true; + if (n.type == "GUILD" && n.record.id && ((hiddenEles.servers || []).includes(n.record.id) || (hiddenEles.folders || []).includes((BDFDB.GuildUtils.getFolder(n.record.id) || {}).folderId))) return false; + else if (n.record.guild_id && ((hiddenEles.servers || []).includes(n.record.guild_id) || (hiddenEles.folders || []).includes((BDFDB.GuildUtils.getFolder(n.record.guild_id) || {}).folderId))) return false; + return true; + }); + } + showHideModal () { let switchInstances = {};