This commit is contained in:
Mirco Wittrien 2019-05-03 17:49:54 +02:00
parent b671fd5239
commit d744f0315c
2 changed files with 25 additions and 14 deletions

View File

@ -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;

View File

@ -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");