From c09d997b2372d5697b2f98ede3c1bec516d23d98 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 14 Aug 2020 00:43:19 +0200 Subject: [PATCH] stuff --- .../ShowHiddenChannels.plugin.js | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js index 2d0cf3a188..3d2a3543de 100644 --- a/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js +++ b/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js @@ -1,7 +1,7 @@ //META{"name":"ShowHiddenChannels","authorId":"278543574059057154","invite":"Jx3TjNS","donate":"https://www.paypal.me/MircoWittrien","patreon":"https://www.patreon.com/MircoWittrien","website":"https://github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/ShowHiddenChannels","source":"https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/ShowHiddenChannels/ShowHiddenChannels.plugin.js"}*// var ShowHiddenChannels = (_ => { - var blacklist = [], hiddenCategory, overrideTypes = []; + var blacklist = [], collapselist = [], hiddenCategory, overrideTypes = []; const settingsMap = { GUILD_TEXT: "showText", @@ -151,7 +151,7 @@ var ShowHiddenChannels = (_ => { children: [ BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsGuildList, { className: BDFDB.disCN.marginbottom20, - disabled: BDFDB.DataUtils.load(this, "blacklist"), + disabled: blacklist, onClick: disabledGuilds => { this.saveBlacklist(disabledGuilds); } @@ -214,6 +214,9 @@ var ShowHiddenChannels = (_ => { let loadedBlacklist = BDFDB.DataUtils.load(this, "blacklist"); this.saveBlacklist(!BDFDB.ArrayUtils.is(loadedBlacklist) ? [] : loadedBlacklist); + let loadedCollapselist = BDFDB.DataUtils.load(this, "categorydata"); + this.saveCollapselist(!BDFDB.ArrayUtils.is(loadedCollapselist) ? [] : loadedCollapselist); + BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.UnreadChannelUtils, "hasUnread", {after: e => { return e.returnValue && !this.isChannelHidden(e.methodArguments[0]); }}); @@ -223,25 +226,23 @@ var ShowHiddenChannels = (_ => { }}); BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseStore, "isCollapsed", {after: e => { - if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) return (BDFDB.DataUtils.load(this, "categorydata", "collapsed") || []).includes(e.methodArguments[0]); + if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) return collapselist.includes(e.methodArguments[0]); }}); BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryCollapse", {before: e => { if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) { - let collapsed = BDFDB.DataUtils.load(this, "categorydata", "collapsed") || []; - if (!collapsed.includes(e.methodArguments[0])) { - collapsed.push(e.methodArguments[0]); - BDFDB.DataUtils.save(collapsed, this, "categorydata", "collapsed"); + if (!collapselist.includes(e.methodArguments[0])) { + collapselist.push(e.methodArguments[0]); + this.saveCollapselist(BDFDB.ArrayUtils.removeCopies(collapselist)); } } }}); BDFDB.ModuleUtils.patch(this, BDFDB.LibraryModules.CategoryCollapseUtils, "categoryExpand", {before: e => { if (e.methodArguments[0] && e.methodArguments[0].endsWith("hidden")) { - let collapsed = BDFDB.DataUtils.load(this, "categorydata", "collapsed") || []; - if (collapsed.includes(e.methodArguments[0])) { - BDFDB.ArrayUtils.remove(collapsed, e.methodArguments[0], true); - BDFDB.DataUtils.save(collapsed, this, "categorydata", "collapsed"); + if (collapselist.includes(e.methodArguments[0])) { + BDFDB.ArrayUtils.remove(collapselist, e.methodArguments[0], true); + this.saveCollapselist(BDFDB.ArrayUtils.removeCopies(collapselist)); } } }}); @@ -457,6 +458,11 @@ var ShowHiddenChannels = (_ => { BDFDB.DataUtils.save(savedBlacklist, this, "blacklist"); } + saveCollapselist (savedCollapselist) { + collapselist = savedCollapselist; + BDFDB.DataUtils.save(savedCollapselist, this, "categorydata"); + } + showAccessModal (channel, allowed) { let guild = BDFDB.LibraryModules.GuildStore.getGuild(channel.guild_id); let myMember = guild && BDFDB.LibraryModules.MemberStore.getMember(guild.id, BDFDB.UserUtils.me.id);