From fe5fb3ed944cdf66c624ec62473b43e5bcbc7595 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Thu, 28 Feb 2019 10:44:12 +0100 Subject: [PATCH] Update PinDMs.plugin.js --- Plugins/PinDMs/PinDMs.plugin.js | 61 +++++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/Plugins/PinDMs/PinDMs.plugin.js b/Plugins/PinDMs/PinDMs.plugin.js index 7a1e32fc9d..744193720f 100644 --- a/Plugins/PinDMs/PinDMs.plugin.js +++ b/Plugins/PinDMs/PinDMs.plugin.js @@ -3,7 +3,7 @@ class PinDMs { getName () {return "PinDMs";} - getVersion () {return "1.3.5";} + getVersion () {return "1.3.6";} getAuthor () {return "DevilBro";} @@ -11,6 +11,7 @@ class PinDMs { initConstructor () { this.changelog = { + "added":[["Pin Icon","Fixed issue where Group DMs could not be pinned"]], "fixed":[["Group DMs","Fixed issue where Group DMs could not be pinned"]] }; @@ -18,7 +19,8 @@ class PinDMs { "Guilds":"componentDidMount", "PrivateChannel":"componentDidMount", "DirectMessage":["componentDidMount","componentDidUpdate","componentWillUnmount"], - "LazyScroller":"render" + "LazyScroller":"render", + "StandardSidebarView":"componentWillUnmount" }; this.dmContextEntryMarkup = @@ -82,6 +84,24 @@ class PinDMs { `; this.css = ` + ${BDFDB.dotCN.dmchannel}.pindms-dragpreview, + ${BDFDB.dotCN.guild}.pindms-dragpreview { + pointer-events: none !important; + position: absolute !important; + opacity: 0.5 !important; + z-index: 10000 !important; + } + ${BDFDB.dotCN.guild}.pindms-dragpreview:before, + ${BDFDB.dotCN.guild}.pindms-dragpreview:after, + ${BDFDB.dotCN.guild}.pindms-dragpreview ${BDFDB.dotCN.badge} { + display: none !important; + } + ${BDFDB.dotCN.guild}.pindms-dragpreview ${BDFDB.dotCN.avataricon} { + background-color: transparent !important; + overflow: hidden !important; + }`; + + this.pinIconCSS = ` ${BDFDB.dotCN.guild}.pinned:after { background-position: 50%; background-repeat: no-repeat; @@ -102,28 +122,22 @@ class PinDMs { } ${BDFDB.dotCNS.themedark + BDFDB.dotCN.guild}.pinned:after { background-color: #202225; + }` + + this.defaults = { + settings: { + showPinIcon: {value:true, description:"Shows a little 'Pin' icon for pinned DMs in the server list:"} } - ${BDFDB.dotCN.dmchannel}.pindms-dragpreview, - ${BDFDB.dotCN.guild}.pindms-dragpreview { - pointer-events: none !important; - position: absolute !important; - opacity: 0.5 !important; - z-index: 10000 !important; - } - ${BDFDB.dotCN.guild}.pindms-dragpreview:before, - ${BDFDB.dotCN.guild}.pindms-dragpreview:after, - ${BDFDB.dotCN.guild}.pindms-dragpreview ${BDFDB.dotCN.badge} { - display: none !important; - } - ${BDFDB.dotCN.guild}.pindms-dragpreview ${BDFDB.dotCN.avataricon} { - background-color: transparent !important; - overflow: hidden !important; - }`; + }; } getSettingsPanel () { if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return; - let settingshtml = `
${this.name}
`; + var settings = BDFDB.getAllData(this, "settings"); + var settingshtml = `
${this.name}
`; + for (let key in settings) { + settingshtml += `

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

`; + } settingshtml += `

Unpin all DMs.

`; settingshtml += `
`; @@ -164,6 +178,8 @@ class PinDMs { if (global.BDFDB && typeof BDFDB === "object" && BDFDB.loaded) { if (this.started) return; BDFDB.loadMessage(this); + + if (BDFDB.getData("showPinIcon", this, "settings")) BDFDB.appendLocalStyle(this.name, this.css + this.pinIconCSS); this.UserUtils = BDFDB.WebModules.findByProperties("getUsers", "getUser"); this.ChannelUtils = BDFDB.WebModules.findByProperties("getChannels", "getChannel"); @@ -416,6 +432,13 @@ class PinDMs { } } + processStandardSidebarView (instance, wrapper) { + if (this.SettingsUpdated) { + delete this.SettingsUpdated; + BDFDB.appendLocalStyle(this.name, this.css + (BDFDB.getData("showPinIcon", this, "settings") ? this.pinIconCSS : "")); + } + } + getInsertPoint (dms) { let insertpoint = null; for (let i in dms) {