mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 18:41:47 +00:00
fix notificationOnUnpause option
This commit is contained in:
@ -25,11 +25,13 @@ const notify = (info, options) => {
|
|||||||
|
|
||||||
const setup = (options) => {
|
const setup = (options) => {
|
||||||
let oldNotification;
|
let oldNotification;
|
||||||
|
let currentUrl;
|
||||||
|
|
||||||
registerCallback(songInfo => {
|
registerCallback(songInfo => {
|
||||||
if (!songInfo.isPaused || options.unpauseNotification) {
|
if (!songInfo.isPaused && (songInfo.url !== currentUrl || options.unpauseNotification)) {
|
||||||
// Close the old notification
|
// Close the old notification
|
||||||
oldNotification?.close();
|
oldNotification?.close();
|
||||||
|
currentUrl = songInfo.url;
|
||||||
// This fixes a weird bug that would cause the notification to be updated instead of showing
|
// This fixes a weird bug that would cause the notification to be updated instead of showing
|
||||||
setTimeout(() => { oldNotification = notify(songInfo, options) }, 10);
|
setTimeout(() => { oldNotification = notify(songInfo, options) }, 10);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,17 +5,20 @@ const notifier = require("node-notifier");
|
|||||||
|
|
||||||
//store song controls reference on launch
|
//store song controls reference on launch
|
||||||
let controls;
|
let controls;
|
||||||
let notificationOnPause;
|
let notificationOnUnpause;
|
||||||
|
|
||||||
module.exports = (win, unpauseNotification) => {
|
module.exports = (win, unpauseNotification) => {
|
||||||
//Save controls and onPause option
|
//Save controls and onPause option
|
||||||
const { playPause, next, previous } = getSongControls(win);
|
const { playPause, next, previous } = getSongControls(win);
|
||||||
controls = { playPause, next, previous };
|
controls = { playPause, next, previous };
|
||||||
notificationOnPause = unpauseNotification;
|
notificationOnUnpause = unpauseNotification;
|
||||||
|
|
||||||
|
let currentUrl;
|
||||||
|
|
||||||
// Register songInfoCallback
|
// Register songInfoCallback
|
||||||
registerCallback(songInfo => {
|
registerCallback(songInfo => {
|
||||||
if (!songInfo.isPaused || notificationOnPause) {
|
if (!songInfo.isPaused && (songInfo.url !== currentUrl || notificationOnUnpause)) {
|
||||||
|
currentUrl = songInfo.url;
|
||||||
sendToaster(songInfo);
|
sendToaster(songInfo);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -78,7 +81,7 @@ function sendToaster(songInfo) {
|
|||||||
// dont delete notification on play/pause
|
// dont delete notification on play/pause
|
||||||
toDelete = undefined;
|
toDelete = undefined;
|
||||||
//manually send notification if not sending automatically
|
//manually send notification if not sending automatically
|
||||||
if (!notificationOnPause) {
|
if (!notificationOnUnpause) {
|
||||||
songInfo.isPaused = false;
|
songInfo.isPaused = false;
|
||||||
sendToaster(songInfo);
|
sendToaster(songInfo);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user