mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 02:31:45 +00:00
refactor notifications plugin
This commit is contained in:
@ -1,18 +1,25 @@
|
||||
const { notificationImage, icons } = require("./utils");
|
||||
const getSongControls = require('../../providers/song-controls');
|
||||
const registerCallback = require("../../providers/song-info");
|
||||
const notifier = require("node-notifier");
|
||||
|
||||
//store song controls reference on launch
|
||||
let controls;
|
||||
let notificationOnPause;
|
||||
|
||||
//Save controls and onPause option
|
||||
module.exports.setupInteractive = (win, unpauseNotification) => {
|
||||
module.exports = (win, unpauseNotification) => {
|
||||
//Save controls and onPause option
|
||||
const { playPause, next, previous } = getSongControls(win);
|
||||
controls = { playPause, next, previous };
|
||||
|
||||
notificationOnPause = unpauseNotification;
|
||||
|
||||
// Register songInfoCallback
|
||||
registerCallback(songInfo => {
|
||||
if (!songInfo.isPaused || notificationOnPause) {
|
||||
sendToaster(songInfo);
|
||||
}
|
||||
});
|
||||
|
||||
win.webContents.once("closed", () => {
|
||||
deleteNotification()
|
||||
});
|
||||
@ -33,7 +40,7 @@ function deleteNotification() {
|
||||
}
|
||||
|
||||
//New notification
|
||||
module.exports.notifyInteractive = function sendToaster(songInfo) {
|
||||
function sendToaster(songInfo) {
|
||||
deleteNotification();
|
||||
//download image and get path
|
||||
let imgSrc = notificationImage(songInfo, true);
|
||||
|
||||
Reference in New Issue
Block a user