diff --git a/Plugins/ServerFolders/ServerFolders.plugin.js b/Plugins/ServerFolders/ServerFolders.plugin.js index 8dddbc72e1..4362ab1888 100644 --- a/Plugins/ServerFolders/ServerFolders.plugin.js +++ b/Plugins/ServerFolders/ServerFolders.plugin.js @@ -14,7 +14,8 @@ class ServerFolders { this.patchModules = { "Guilds":"componentDidMount", - "Guild":["componentDidMount","componentWillUnmount"] + "Guild":["componentDidMount","componentWillUnmount"], + "StandardSidebarView":"componentWillUnmount" }; this.css = ` @@ -497,8 +498,7 @@ class ServerFolders { }); BDFDB.addEventListener(this, wrapper, "mousedown", e => { if (BDFDB.pressedKeys.includes(17)) { - e.originalEvent.stopPropagation(); - e.originalEvent.preventDefault(); + BDFDB.stopEvent(e); let dragpreview = this.createDragPreview(wrapper, e); let updatePreview = e2 => { this.updateDragPreview(dragpreview, e2); @@ -525,6 +525,13 @@ class ServerFolders { } } + processStandardSidebarView (instance, wrapper) { + if (this.SettingsUpdated) { + delete this.SettingsUpdated; + this.foldercontent.querySelectorAll(BDFDB.dotCN.guild + ".folder").forEach(folderdiv => {this.updateFolderNotifications(folderdiv);}); + } + } + showFolderSettings (folderdiv) { if (!folderdiv) return; let {folderID,folderName,position,iconID,icons,copyTooltipColor,color1,color2,color3,color4,servers} = BDFDB.loadData(folderdiv.id, this, "folders") || {}; @@ -557,8 +564,6 @@ class ServerFolders { this.saveCustomIcon(folderSettingsModal); }); BDFDB.addChildEventListener(folderSettingsModal, "click", ".btn-save", e => { - e.preventDefault(); - folderName = foldernameinput.value.trim(); folderName = folderName ? folderName : null; @@ -855,7 +860,7 @@ class ServerFolders { BDFDB.removeClass(unreaditem, BDFDB.disCN.contextmenuitemdisabled); unreaditem.addEventListener("click", () => { folderContext.remove(); - BDFDB.clearReadNotifications(unreadServers); + BDFDB.markGuildAsRead(unreadServers); }); } BDFDB.appendContextMenu(folderContext, e); @@ -1080,7 +1085,7 @@ class ServerFolders { BDFDB.createTooltip(EditServersData.name || info.name, guildcopy, {type:"right",selector:(!BDFDB.isObjectEmpty(EditServersData) ? "EditUsers-tooltip" : ""),style:`color: ${fontColor} !important; background-color: ${bgColor} !important; border-color: ${bgColor} !important;`}); }); guildcopy.addEventListener("click", e => { - e.preventDefault(); + BDFDB.stopEvent(e); if (BDFDB.pressedKeys.includes(46)) this.removeServerFromFolder(info, folderdiv); else { let settings = BDFDB.getAllData(this, "settings"); @@ -1200,7 +1205,7 @@ class ServerFolders { if (!data) return; let includedServers = this.readIncludedServerList(folderdiv); let unreadServers = BDFDB.readUnreadServerList(includedServers); - if (unreadServers.length > 0 && data.autounread) BDFDB.clearReadNotifications(unreadServers); + if (unreadServers.length > 0 && data.autounread) BDFDB.markGuildAsRead(unreadServers); else { let badgeAmount = 0; let audioEnabled = false; diff --git a/PluginsV2/ReadAllNotificationsButton/index.js b/PluginsV2/ReadAllNotificationsButton/index.js index b5207cfd08..12fe3dacad 100644 --- a/PluginsV2/ReadAllNotificationsButton/index.js +++ b/PluginsV2/ReadAllNotificationsButton/index.js @@ -8,6 +8,24 @@ module.exports = (Plugin, Api, Vendor) => { "RecentMentions":"componentDidMount" }; + this.RANcontextMenuMarkup = + `
+
+
+
REPLACE_context_guilds_text
+
+
+
+
REPLACE_context_mutedguilds_text
+
+
+
+
REPLACE_context_dms_text
+
+
+
+
`; + this.RANbuttonMarkup = `
@@ -24,7 +42,9 @@ module.exports = (Plugin, Api, Vendor) => { this.defaults = { settings: { - includeMuted: {value:false, description:"Include muted Servers (means more API-Requests):"} + includeGuilds: {value:true, description:"unread Servers"}, + includeMuted: {value:false, description:"muted unread Servers"}, + includeDMs: {value:false, description:"unread DMs"} } }; } @@ -83,7 +103,25 @@ module.exports = (Plugin, Api, Vendor) => { let ranbutton = BDFDB.htmlToElement(this.RANbuttonMarkup); guildseparator.parentElement.insertBefore(ranbutton, guildseparator); ranbutton.addEventListener("click", () => { - BDFDB.clearReadNotifications(BDFDB.getData("includeMuted", this, "settings") ? BDFDB.readServerList() : BDFDB.readUnreadServerList()); + let settings = BDFDB.getAllData(this, "settings"); + if (settings.includeGuilds) BDFDB.markGuildAsRead(settings.includeMuted ? BDFDB.readServerList() : BDFDB.readUnreadServerList()); + if (settings.includeDMs) BDFDB.markChannelAsRead(BDFDB.readDmList()); + }); + ranbutton.addEventListener("contextmenu", e => { + let RANcontextMenu = BDFDB.htmlToElement(this.RANcontextMenuMarkup); + RANcontextMenu.querySelector(".readguilds-item").addEventListener("click", () => { + BDFDB.removeEles(RANcontextMenu); + BDFDB.markGuildAsRead(BDFDB.readUnreadServerList()); + }); + RANcontextMenu.querySelector(".readmutedguilds-item").addEventListener("click", () => { + BDFDB.removeEles(RANcontextMenu); + BDFDB.markGuildAsRead(BDFDB.readServerList()); + }); + RANcontextMenu.querySelector(".readdms-item").addEventListener("click", () => { + BDFDB.removeEles(RANcontextMenu); + BDFDB.markChannelAsRead(BDFDB.readDmList()); + }); + BDFDB.appendContextMenu(RANcontextMenu, e); }); BDFDB.addClass(wrapper, "RAN-added"); } @@ -115,14 +153,22 @@ module.exports = (Plugin, Api, Vendor) => { if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; var settings = BDFDB.getAllData(this, "settings"); var settingshtml = `
${this.name}
`; + settingshtml += `

When left clicking the button mark following elements as unread:

`; for (let key in settings) { - settingshtml += `

${this.defaults.settings[key].description}

`; + settingshtml += `

${this.defaults.settings[key].description}

`; } + settingshtml += `
`; settingshtml += `
`; let settingspanel = BDFDB.htmlToElement(settingshtml); BDFDB.initElements(settingspanel, this); + + let mutedinput = settingspanel.querySelector(".settings-switch[value='settings includeMuted']").parentElement.parentElement; + BDFDB.toggleEles(mutedinput, settings.includeGuilds); + BDFDB.addEventListener(this, settingspanel, "click", ".settings-switch[value='settings includeGuilds']", e => { + BDFDB.toggleEles(mutedinput, e.currentTarget.checked); + }); return settingspanel; } diff --git a/PluginsV2/ServerFolders/index.js b/PluginsV2/ServerFolders/index.js index 9efde512d0..1b29b050a1 100644 --- a/PluginsV2/ServerFolders/index.js +++ b/PluginsV2/ServerFolders/index.js @@ -794,7 +794,7 @@ module.exports = (Plugin, Api, Vendor) => { BDFDB.removeClass(unreaditem, BDFDB.disCN.contextmenuitemdisabled); unreaditem.addEventListener("click", () => { folderContext.remove(); - BDFDB.clearReadNotifications(unreadServers); + BDFDB.markGuildAsRead(unreadServers); }); } BDFDB.appendContextMenu(folderContext, e); @@ -1139,7 +1139,7 @@ module.exports = (Plugin, Api, Vendor) => { if (!data) return; let includedServers = this.readIncludedServerList(folderdiv); let unreadServers = BDFDB.readUnreadServerList(includedServers); - if (unreadServers.length > 0 && data.autounread) BDFDB.clearReadNotifications(unreadServers); + if (unreadServers.length > 0 && data.autounread) BDFDB.markGuildAsRead(unreadServers); else { let badgeAmount = 0; let audioEnabled = false;