From 81246231426856b83d9bb1cfe90aba63d43ba10a Mon Sep 17 00:00:00 2001 From: Araxeus Date: Sat, 22 May 2021 18:38:36 +0300 Subject: [PATCH] fix notificationOnUnpause option --- plugins/notifications/back.js | 4 +++- plugins/notifications/interactive.js | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/plugins/notifications/back.js b/plugins/notifications/back.js index 59b934c9..654e3b54 100644 --- a/plugins/notifications/back.js +++ b/plugins/notifications/back.js @@ -25,11 +25,13 @@ const notify = (info, options) => { const setup = (options) => { let oldNotification; + let currentUrl; registerCallback(songInfo => { - if (!songInfo.isPaused || options.unpauseNotification) { + if (!songInfo.isPaused && (songInfo.url !== currentUrl || options.unpauseNotification)) { // Close the old notification oldNotification?.close(); + currentUrl = songInfo.url; // This fixes a weird bug that would cause the notification to be updated instead of showing setTimeout(() => { oldNotification = notify(songInfo, options) }, 10); } diff --git a/plugins/notifications/interactive.js b/plugins/notifications/interactive.js index 210402bf..c30c1020 100644 --- a/plugins/notifications/interactive.js +++ b/plugins/notifications/interactive.js @@ -5,17 +5,20 @@ const notifier = require("node-notifier"); //store song controls reference on launch let controls; -let notificationOnPause; +let notificationOnUnpause; module.exports = (win, unpauseNotification) => { //Save controls and onPause option const { playPause, next, previous } = getSongControls(win); controls = { playPause, next, previous }; - notificationOnPause = unpauseNotification; + notificationOnUnpause = unpauseNotification; + + let currentUrl; // Register songInfoCallback registerCallback(songInfo => { - if (!songInfo.isPaused || notificationOnPause) { + if (!songInfo.isPaused && (songInfo.url !== currentUrl || notificationOnUnpause)) { + currentUrl = songInfo.url; sendToaster(songInfo); } }); @@ -78,7 +81,7 @@ function sendToaster(songInfo) { // dont delete notification on play/pause toDelete = undefined; //manually send notification if not sending automatically - if (!notificationOnPause) { + if (!notificationOnUnpause) { songInfo.isPaused = false; sendToaster(songInfo); }