From d744f0315c13c9ce8630db0f30a93f379750e439 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Fri, 3 May 2019 17:49:54 +0200 Subject: [PATCH] big off --- .../ReadAllNotificationsButton.plugin.js | 7 ++-- Plugins/ServerFolders/ServerFolders.plugin.js | 32 ++++++++++++------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js index 0e7beb1b3c..f6515ddb86 100644 --- a/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js +++ b/Plugins/ReadAllNotificationsButton/ReadAllNotificationsButton.plugin.js @@ -3,7 +3,7 @@ class ReadAllNotificationsButton { getName () {return "ReadAllNotificationsButton";} - getVersion () {return "1.4.7";} + getVersion () {return "1.4.8";} getAuthor () {return "DevilBro";} @@ -11,11 +11,11 @@ class ReadAllNotificationsButton { initConstructor () { this.changelog = { - "fixed":[["Button above home button","Fixed the issue where the read all button would sometimes appear above the home button"]] + "fixed":[["Issue with other plugins","Fixed the issue where the 'read all' button would move aroudn the serverlist, when another plugin forces server list to rerender"]] }; this.patchModules = { - "Guilds":"componentDidMount", + "Guilds":["componentDidMount","componentDidUpdate"], "RecentMentions":"componentDidMount", "DirectMessage":"componentDidMount" }; @@ -208,6 +208,7 @@ class ReadAllNotificationsButton { getInsertNode () { let homebutton = BDFDB.getParentEle(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCN.homebuttonicon)); + if (!homebutton) return null; let nextsibling = homebutton.nextElementSibling, insertnode = null; while (nextsibling && insertnode == null) { if (nextsibling.querySelector(`${BDFDB.dotCN.guildseparator}:not(.folderseparator)`)) insertnode = nextsibling; diff --git a/Plugins/ServerFolders/ServerFolders.plugin.js b/Plugins/ServerFolders/ServerFolders.plugin.js index 111b203496..86c1e22e53 100644 --- a/Plugins/ServerFolders/ServerFolders.plugin.js +++ b/Plugins/ServerFolders/ServerFolders.plugin.js @@ -3,7 +3,7 @@ class ServerFolders { getName () {return "ServerFolders";} - getVersion () {return "6.2.2";} + getVersion () {return "6.2.3";} getAuthor () {return "DevilBro";} @@ -11,14 +11,13 @@ class ServerFolders { initConstructor () { this.changelog = { - "added":[["Everything","Thanks you for all the people that actually reached out to me and donated to me <3"]], - "fixed":[["Unread Pill","Fixed the issue where the unread indicator would get stuck if you quickly hover between folders/servers"]] + "fixed":[["Issue with other plugins","Fixed the issue where Folders would be moved to the top of the serverlist, when another plugin forces server list to rerender"]] }; this.labels = {}; this.patchModules = { - "Guilds":["componentDidMount","componentWillUnmount"], + "Guilds":["componentDidMount","componentDidUpdate","componentWillUnmount"], "Guild":["componentDidMount","componentWillUnmount"], "StandardSidebarView":"componentWillUnmount" }; @@ -578,6 +577,12 @@ class ServerFolders { if (document.querySelector(BDFDB.dotCNS.guildswrapper + BDFDB.dotCN.guildouter + ":not(.folder):not(.copy) " + BDFDB.dotCN.guildicon)) process(); else setTimeout(process, 5000); } + if (methodnames.includes("componentDidUpdate")) { + let folders = BDFDB.loadAllData(this, "folders") + for (let folderdiv of document.querySelectorAll(BDFDB.dotCN.guildouter + ".folder")) { + if (folders[folderdiv.id]) this.insertFolderDiv(folders[folderdiv.id], folderdiv); + } + } } processGuild (instance, wrapper, methodnames) { @@ -909,13 +914,7 @@ class ServerFolders { createFolderDiv (data) { let folderdiv = BDFDB.htmlToElement(this.folderIconMarkup); let folderdivinner = folderdiv.querySelector(BDFDB.dotCN.guildcontainer); - let serversandfolders = this.getAllServersAndFolders(); - let insertnode = serversandfolders[data.position > serversandfolders.length - 1 ? serversandfolders.length - 1 : data.position]; - if (insertnode) insertnode.parentElement.insertBefore(folderdiv, insertnode); - else { - insertnode = BDFDB.getParentEle(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCNS.guilds + BDFDB.dotCN.guildbuttoncontainer)); - if (insertnode) insertnode.parentElement.parentElement.insertBefore(folderdiv, insertnode.parentElement); - } + this.insertFolderDiv(data, folderdiv); folderdiv.id = data.folderID; folderdiv.setAttribute("foldername", data.folderName); @@ -1029,6 +1028,17 @@ class ServerFolders { return folderdiv; } + + insertFolderDiv (data, folderdiv) { + folderdiv.remove(); + let serversandfolders = this.getAllServersAndFolders(); + let insertnode = serversandfolders[data.position > serversandfolders.length - 1 ? serversandfolders.length - 1 : data.position]; + if (insertnode) insertnode.parentElement.insertBefore(folderdiv, insertnode); + else { + insertnode = BDFDB.getParentEle(BDFDB.dotCN.guildouter, document.querySelector(BDFDB.dotCNS.guilds + BDFDB.dotCN.guildbuttoncontainer)); + if (insertnode) insertnode.parentElement.parentElement.insertBefore(folderdiv, insertnode.parentElement); + } + } generateID (prefix) { let data = BDFDB.loadAllData(this, prefix + "s");