refactor notifications plugin

This commit is contained in:
Araxeus
2021-05-10 05:00:58 +03:00
parent 7cf78c6635
commit cb743de7fd
2 changed files with 28 additions and 36 deletions

View File

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