Update ServerHider.plugin.js

This commit is contained in:
Mirco Wittrien 2023-11-06 15:38:01 +01:00
parent f6bc4b5cac
commit 37ed3f2e3f
1 changed files with 24 additions and 2 deletions

View File

@ -2,7 +2,7 @@
* @name ServerHider * @name ServerHider
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 6.2.8 * @version 6.2.9
* @description Allows you to hide certain Servers in your Server List * @description Allows you to hide certain Servers in your Server List
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -67,6 +67,9 @@ module.exports = (_ => {
}; };
this.modulePatches = { this.modulePatches = {
before: [
"QuickSwitcher"
],
after: [ after: [
"GuildsBar" "GuildsBar"
] ]
@ -80,6 +83,15 @@ module.exports = (_ => {
if (e.methodArguments[0].type == "STREAMER_MODE_UPDATE") BDFDB.DiscordUtils.rerenderAll(true); 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 => { BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.SortedGuildStore, "getGuildFolderById", {after: e => {
let hiddenGuildIds = hiddenEles.servers || []; let hiddenGuildIds = hiddenEles.servers || [];
if (e.returnValue && hiddenGuildIds.length) { if (e.returnValue && hiddenGuildIds.length) {
@ -93,7 +105,7 @@ module.exports = (_ => {
BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.GuildReadStateStore, "getMutableGuildStates", {after: e => { BDFDB.PatchUtils.patch(this, BDFDB.LibraryStores.GuildReadStateStore, "getMutableGuildStates", {after: e => {
if (!e.returnValue || this.settings.general.onlyHideInStream && !BDFDB.LibraryStores.StreamerModeStore.enabled) return; if (!e.returnValue || this.settings.general.onlyHideInStream && !BDFDB.LibraryStores.StreamerModeStore.enabled) return;
let hiddenGuildIds = hiddenEles && hiddenEles.servers || []; 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(); 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 () { showHideModal () {
let switchInstances = {}; let switchInstances = {};