From b78fe25cb2542e785a24fa7a397dab38f2f89ba0 Mon Sep 17 00:00:00 2001 From: Mirco Wittrien Date: Wed, 2 Oct 2019 12:53:51 +0200 Subject: [PATCH] stuff --- .../FriendNotifications.plugin.js | 36 ++++++++++--------- Plugins/ThemeRepo/res/ThemeList.txt | 6 ++++ 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/Plugins/FriendNotifications/FriendNotifications.plugin.js b/Plugins/FriendNotifications/FriendNotifications.plugin.js index 23b2a2ed29..224d3b28b6 100644 --- a/Plugins/FriendNotifications/FriendNotifications.plugin.js +++ b/Plugins/FriendNotifications/FriendNotifications.plugin.js @@ -3,7 +3,7 @@ class FriendNotifications { getName () {return "FriendNotifications";} - getVersion () {return "1.3.1";} + getVersion () {return "1.3.2";} getAuthor () {return "DevilBro";} @@ -11,6 +11,7 @@ class FriendNotifications { constructor () { this.changelog = { + "added":[["Toast/Desktop Time","The amount of seconds a toast or desktop notification is on screen can now be configured in the settings"]], "fixed":[["Double notifications","It now should be impossible for the plugin to trigger double notifications, if this problem still occurs to you, then something is wrong on your end (double plugin file or two different versions at the same time)"]] }; @@ -21,7 +22,6 @@ class FriendNotifications { initConstructor () { this.userStatusStore = {}; - this.shownNotifications = {}; this.checkInterval = null; @@ -133,6 +133,8 @@ class FriendNotifications { }, notificationsounds: {}, amounts: { + toastTime: {value:5, min:1, description:"Amount of seconds a toast notification stays on screen:"}, + desktopTime: {value:5, min:1, description:"Amount of seconds a desktop notification stays on screen:"}, checkInterval: {value:10, min:5, description:"Check Users every X seconds:"} } }; @@ -161,7 +163,7 @@ class FriendNotifications { let settingshtml = `
${this.name}
`; settingshtml += `
General Settings
`; for (let key in settings) settingshtml += `

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

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

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

`; + for (let key in amounts) if (key.indexOf("desktop") == -1 || "Notification" in window) settingshtml += `

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

`; settingshtml += `
`; settingshtml += `
Friend-List
`; settingshtml += `

Click on an Icon to toggle Notifications for that User:

`; @@ -491,11 +493,13 @@ class FriendNotifications { startInterval () { clearInterval(this.checkInterval); let settings = BDFDB.getAllData(this, "settings"); + let amounts = BDFDB.getAllData(this, "amounts"); let notificationstrings = BDFDB.getAllData(this, "notificationstrings"); let notificationsounds = BDFDB.getAllData(this, "notificationsounds"); let users = Object.assign({}, BDFDB.loadAllData(this, "nonfriends"), BDFDB.loadAllData(this, "friends")); for (let id in users) this.userStatusStore[id] = this.getStatusWithMobileAndActivity(id, users[id]).statusname; - let intervaltime = BDFDB.getData("checkInterval", this, "amounts") * 1000; + let toasttime = (amounts.toastTime > amounts.checkInterval ? amounts.checkInterval : amounts.toastTime) * 1000; + let desktoptime = (amounts.desktopTime > amounts.checkInterval ? amounts.checkInterval : amounts.desktopTime) * 1000; this.checkInterval = setInterval(() => { for (let id in users) if (!users[id].disabled) { let user = BDFDB.LibraryModules.UserStore.getUser(id); @@ -508,8 +512,7 @@ class FriendNotifications { if (status.isactivity) toaststring = toaststring.replace(/\$song|\$game/g, `${status.name || status.details}`).replace(/\$artist/g, `${status.state}`); let avatar = EUdata.removeIcon ? "" : (EUdata.url ? EUdata.url : BDFDB.getUserAvatar(user.id)); this.timeLog.push({string:toaststring, avatar, time: new Date()}); - if (!(settings.muteOnDND && BDFDB.getUserStatus() == "dnd") && !this.shownNotifications[user.id]) { - this.shownNotifications[user.id] = true; + if (!(settings.muteOnDND && BDFDB.getUserStatus() == "dnd")) { let openChannel = () => { if (settings.openOnClick) { let DMid = BDFDB.LibraryModules.ChannelStore.getDMFromUserId(user.id) @@ -519,27 +522,28 @@ class FriendNotifications { } }; if (!users[id].desktop) { - let toast = BDFDB.showToast(`
${toaststring}
`, {html:true, timeout:5000, color:BDFDB.getUserStatusColor(status.statusname), icon:false, selector:`friendnotifications-${status.statusname}-toast`}); - toast.addEventListener("click", openChannel); - let notificationsound = notificationsounds["toast" + status.statusname] || {}; - if (!notificationsound.mute && notificationsound.song) { - let audio = new Audio(); - audio.src = notificationsound.song; - audio.play(); + if (!document.querySelector(`.friendnotifications-${id}-toast`)) { + let toast = BDFDB.showToast(`
${toaststring}
`, {html:true, timeout:toasttime, color:BDFDB.getUserStatusColor(status.statusname), icon:false, selector:`friendnotifications-${status.statusname}-toast friendnotifications-${id}-toast`}); + toast.addEventListener("click", openChannel); + let notificationsound = notificationsounds["toast" + status.statusname] || {}; + if (!notificationsound.mute && notificationsound.song) { + let audio = new Audio(); + audio.src = notificationsound.song; + audio.play(); + } } } else { let desktopstring = string.replace(/\$user/g, EUdata.name || user.username).replace(/\$status/g, libstring); if (status.isactivity) desktopstring = desktopstring.replace(/\$song|\$game/g, status.name || status.details).replace(/\$artist/g, status.state); let notificationsound = notificationsounds["desktop" + status.statusname] || {}; - BDFDB.showDesktopNotification(desktopstring, {icon:avatar, timeout:5000, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song}); + BDFDB.showDesktopNotification(desktopstring, {icon:avatar, timeout:desktoptime, click:openChannel, silent:notificationsound.mute, sound:notificationsound.song}); } - setTimeout(() => {delete this.shownNotifications[user.id]}, intervaltime/2); } } this.userStatusStore[id] = status.statusname; } - }, intervaltime); + }, amounts.checkInterval * 1000); } showTimeLog () { diff --git a/Plugins/ThemeRepo/res/ThemeList.txt b/Plugins/ThemeRepo/res/ThemeList.txt index ecd7479bdd..b76867a70f 100644 --- a/Plugins/ThemeRepo/res/ThemeList.txt +++ b/Plugins/ThemeRepo/res/ThemeList.txt @@ -19,9 +19,15 @@ https://raw.githubusercontent.com/CurimuChizu/CC-Themes/master/CC-Themes/ReZero. https://raw.githubusercontent.com/Dddsasul/TeamKappa-theme/master/ClearDiscord.theme.css https://raw.githubusercontent.com/Dddsasul/TeamKappa-theme/master/JustBlack.theme.css https://raw.githubusercontent.com/denBot/Cyan-Firewatch/master/cyan-firewatch.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/BNHA.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/BubblesReturns.theme.css https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/Calm_and_Peaceful_Street.theme.css https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/CleanGreenForest.theme.css https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/Great_Mountain_Site.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/Kemono_Friends.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/TeamRam.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/TeamRem.theme.css +https://raw.githubusercontent.com/DevilsLynAvenged/DevilsLynAvenged/master/My_Theme_Collection/Winter_Returns.theme.css https://raw.githubusercontent.com/fluffingtons/fulldark/master/fulldark.theme.css https://raw.githubusercontent.com/Gibbu/BetterDiscord-Themes/master/AdjustableServerWidth/AdjustableServerWidth.theme.css https://raw.githubusercontent.com/Gibbu/BetterDiscord-Themes/master/FrostedGlass/FrostedGlass.theme.css