diff --git a/config/defaults.js b/config/defaults.js index f3cd7f04..57c001b1 100644 --- a/config/defaults.js +++ b/config/defaults.js @@ -45,7 +45,7 @@ const defaultConfig = { enabled: false, urgency: "normal", unpauseNotification: false, - interactive: true //has effect only on Windows 8+ + interactive: false //has effect only on Windows 8+ } }, }; diff --git a/plugins/notifications/back.js b/plugins/notifications/back.js index 31162320..38fbbbf8 100644 --- a/plugins/notifications/back.js +++ b/plugins/notifications/back.js @@ -27,7 +27,7 @@ module.exports = (win, options) => { const isInteractive = is.windows() && options.interactive; //setup interactive notifications for windows if (isInteractive) { - setupInteractive(win); + setupInteractive(win, options.unpauseNotification); } const registerCallback = getSongInfo(win); let oldNotification; diff --git a/plugins/notifications/interactive.js b/plugins/notifications/interactive.js index 06999153..b7ff461a 100644 --- a/plugins/notifications/interactive.js +++ b/plugins/notifications/interactive.js @@ -4,10 +4,14 @@ const notifier = require("node-notifier"); //store song controls reference on launch let controls; -module.exports.setupInteractive = (win) => { - //save controls +let onPause; + +//Save controls and onPause option +module.exports.setupInteractive = (win, unpauseNotification) => { const { playPause, next, previous } = getSongControls(win); controls = { playPause, next, previous }; + + onPause = unpauseNotification; } //delete old notification @@ -24,10 +28,13 @@ function Delete() { } //New notification -module.exports.notifyInteractive = (songInfo) => { +module.exports.notifyInteractive = function sendToaster(songInfo) { + console.log("called toaster"); Delete(); + console.log("deleted"); //download image and get path let imgSrc = notificationImage(songInfo, true); + console.log("got image"); toDelete = { //app id undefined - will break buttons title: songInfo.title || "Playing", @@ -41,6 +48,7 @@ module.exports.notifyInteractive = (songInfo) => { ], sound: false, }; + console.log("sending notification"); //send notification notifier.notify( toDelete, @@ -59,12 +67,18 @@ module.exports.notifyInteractive = (songInfo) => { return; case icons.play.normalize(): controls.playPause(); - toDelete = undefined; // dont delete notification on play/pause + // dont delete notification on play/pause + toDelete = undefined; + //manually send notification if not sending automatically + if (!onPause) { + songInfo.isPaused = false; + sendToaster(songInfo); + } return; case icons.pause.normalize(): controls.playPause(); songInfo.isPaused = true; - toDelete = undefined; // it gets deleted automatically + toDelete = undefined; sendToaster(songInfo); return; //Native datatype diff --git a/plugins/notifications/utils.js b/plugins/notifications/utils.js index 42c406d9..17b96091 100644 --- a/plugins/notifications/utils.js +++ b/plugins/notifications/utils.js @@ -1,9 +1,9 @@ const { setOptions } = require("../../config/plugins"); const path = require("path"); const { app } = require("electron"); -const icon = path.join(__dirname, "assets", "youtube-music.png"); const fs = require("fs"); +const icon = "assets/youtube-music.png"; const tempIcon = path.join(app.getPath("userData"), "tempIcon.png"); module.exports.urgencyLevels = [