diff --git a/plugins/notifications/back.js b/plugins/notifications/back.js index d70898cc..e0e98407 100644 --- a/plugins/notifications/back.js +++ b/plugins/notifications/back.js @@ -2,7 +2,7 @@ const { Notification } = require("electron"); const getSongInfo = require("../../providers/song-info"); -const notify = (info) => { +const notify = (info, notification) => { let notificationImage = "assets/youtube-music.png"; if (info.image) { @@ -10,25 +10,31 @@ const notify = (info) => { } // Fill the notification with content - const notification = { - title: info.title || "Playing", - body: info.artist, - icon: notificationImage, - silent: true, - }; + notification.title = info.title || "Playing"; + notification.body = info.artist; + notification.icon = notificationImage; + // Send the notification - new Notification(notification).show(); + notification.show(); }; module.exports = (win) => { const registerCallback = getSongInfo(win); - + + // Create a notification + let notification = new Notification( { + title:'', + body: '', + icon: "assets/youtube-music.png", + silent: true, + }); + win.on("ready-to-show", () => { // Register the callback for new song information registerCallback((songInfo) => { // If song is playing send notification if (!songInfo.isPaused) { - notify(songInfo); + notify(songInfo, notification); } }); });