Update PinDMs.plugin.js

This commit is contained in:
Mirco Wittrien 2023-07-25 18:16:06 +02:00
parent e6f2f4cfb0
commit c761165f09
1 changed files with 12 additions and 9 deletions

View File

@ -2,7 +2,7 @@
* @name PinDMs * @name PinDMs
* @author DevilBro * @author DevilBro
* @authorId 278543574059057154 * @authorId 278543574059057154
* @version 2.0.0 * @version 2.0.1
* @description Allows you to pin DMs, making them appear at the top of your DMs/ServerList * @description Allows you to pin DMs, making them appear at the top of your DMs/ServerList
* @invite Jx3TjNS * @invite Jx3TjNS
* @donate https://www.paypal.me/MircoWittrien * @donate https://www.paypal.me/MircoWittrien
@ -526,7 +526,7 @@ module.exports = (_ => {
if (!this.settings.preCategories[category.id]) return; if (!this.settings.preCategories[category.id]) return;
this.settings.preCategories[category.id].enabled = false; this.settings.preCategories[category.id].enabled = false;
BDFDB.DataUtils.save(this.settings.preCategories, this, "preCategories"); BDFDB.DataUtils.save(this.settings.preCategories, this, "preCategories");
this.updateContainer("channelList"); this.updateContainer("channelList", true);
} }
}) : [ }) : [
BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, { BDFDB.ContextMenuUtils.createItem(BDFDB.LibraryComponents.MenuItems.MenuItem, {
@ -542,7 +542,7 @@ module.exports = (_ => {
let newData = this.getPinnedChannels("channelList"); let newData = this.getPinnedChannels("channelList");
delete newData[category.id]; delete newData[category.id];
this.savePinnedChannels(newData, "channelList"); this.savePinnedChannels(newData, "channelList");
this.updateContainer("channelList"); this.updateContainer("channelList", true);
} }
}) })
] ]
@ -754,7 +754,7 @@ module.exports = (_ => {
if (!category.dms.includes(id)) category.dms.unshift(id); if (!category.dms.includes(id)) category.dms.unshift(id);
this.savePinnedChannels(Object.assign({}, this.getPinnedChannels(type), {[category.id]: category}), type); this.savePinnedChannels(Object.assign({}, this.getPinnedChannels(type), {[category.id]: category}), type);
if (wasEmpty && category.dms.length) category.collapsed = false; if (wasEmpty && category.dms.length) category.collapsed = false;
this.updateContainer(type); this.updateContainer(type, true);
} }
removeFromCategory (id, category, type) { removeFromCategory (id, category, type) {
@ -762,7 +762,7 @@ module.exports = (_ => {
BDFDB.ArrayUtils.remove(category.dms, id, true); BDFDB.ArrayUtils.remove(category.dms, id, true);
if (!this.filterDMs(category.dms).length) category.collapsed = true; if (!this.filterDMs(category.dms).length) category.collapsed = true;
this.savePinnedChannels(Object.assign({}, this.getPinnedChannels(type), {[category.id]: category}), type); this.savePinnedChannels(Object.assign({}, this.getPinnedChannels(type), {[category.id]: category}), type);
this.updateContainer(type); this.updateContainer(type, true);
} }
getChannelListCategory (id) { getChannelListCategory (id) {
@ -903,12 +903,15 @@ module.exports = (_ => {
return this.getPinnedChannels("guildList")[id] != undefined; return this.getPinnedChannels("guildList")[id] != undefined;
} }
updateContainer (type) { updateContainer (type, force) {
switch (type) { switch (type) {
case "channelList": case "channelList":
if (!channelListIsRenderendering) BDFDB.DiscordUtils.rerenderAll(true); if (force) {
channelListIsRenderendering = true; if (!channelListIsRenderendering) BDFDB.DiscordUtils.rerenderAll(true);
BDFDB.TimeUtils.timeout(_ => channelListIsRenderendering = false, 3000); channelListIsRenderendering = true;
BDFDB.TimeUtils.timeout(_ => channelListIsRenderendering = false, 3000);
}
else BDFDB.PatchUtils.forceAllUpdates(this, "PrivateChannelsList");
break; break;
case "guildList": case "guildList":
BDFDB.DiscordUtils.rerenderAll(true); BDFDB.DiscordUtils.rerenderAll(true);