fix unPause option compatibility

This commit is contained in:
Araxeus
2021-04-09 03:15:57 +03:00
parent 095196785a
commit 9c0a633677
4 changed files with 22 additions and 8 deletions

View File

@ -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+
}
},
};

View File

@ -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;

View File

@ -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

View File

@ -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 = [