From 91c4988d40d191dec82a7521caa360050a127d9b Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 22 Nov 2019 14:38:30 +0100 Subject: [PATCH] Update ServerHider.plugin.js --- Plugins/ServerHider/ServerHider.plugin.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Plugins/ServerHider/ServerHider.plugin.js b/Plugins/ServerHider/ServerHider.plugin.js index ca5fa28046..26651b475b 100644 --- a/Plugins/ServerHider/ServerHider.plugin.js +++ b/Plugins/ServerHider/ServerHider.plugin.js @@ -77,6 +77,16 @@ class ServerHider { BDFDB.DataUtils.save(olddata, this, "hidden", "servers"); BDFDB.DataUtils.remove(this, "hiddenservers"); } + + BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.FolderStore, "getGuildFolderById", {after: e => { + let hiddenGuildIds = BDFDB.DataUtils.load(this, "hidden", "servers") || []; + if (e.returnValue && hiddenGuildIds.length) { + let folder = Object.assign({}, e.returnValue); + folder.guildIds = [].concat(folder.guildIds).filter(n => !hiddenGuildIds.includes(n)); + folder.hiddenGuildIds = [].concat(folder.guildIds).filter(n => hiddenGuildIds.includes(n)); + return folder; + } + }}); BDFDB.ModuleUtils.forceAllUpdates(this); } @@ -142,7 +152,10 @@ class ServerHider { if (hiddenFolderIds.includes(child.props.folderId)) children[i] = null; else { let guildIds = [].concat(child.props.guildIds.filter(guildId => !hiddenGuildIds.includes(guildId))); - if (guildIds.length) child.props.guildIds = guildIds; + if (guildIds.length) { + child.props.hiddenGuildIds = [].concat(child.props.guildIds.filter(guildId => hiddenGuildIds.includes(guildId))); + child.props.guildIds = guildIds; + } else children[i] = null; } }