Use refactored provider in notification plugin

This commit is contained in:
TC
2021-01-12 21:18:05 +01:00
parent 9110e79c16
commit de1e4196d9

View File

@ -1,7 +1,9 @@
const { Notification } = require("electron");
const notify = info => {
let notificationImage = 'assets/youtube-music.png';
const getSongInfo = require("../../providers/song-info");
const notify = (info) => {
let notificationImage = "assets/youtube-music.png";
if (info.image) {
notificationImage = info.image.resize({ height: 256, width: 256 });
@ -18,10 +20,12 @@ const notify = info => {
new Notification(notification).show();
};
module.exports = win => {
win.on('ready-to-show', () => {
module.exports = (win) => {
const registerCallback = getSongInfo(win);
win.on("ready-to-show", () => {
// Register the callback for new song information
global.songInfo.onNewData(songInfo => {
registerCallback((songInfo) => {
// If song is playing send notification
if (!songInfo.isPaused) {
notify(songInfo);