From de1e4196d9dd841f9344ad8bcaf2b30b03836589 Mon Sep 17 00:00:00 2001 From: TC Date: Tue, 12 Jan 2021 21:18:05 +0100 Subject: [PATCH] Use refactored provider in notification plugin --- plugins/notifications/back.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/plugins/notifications/back.js b/plugins/notifications/back.js index a55bffe4..d70898cc 100644 --- a/plugins/notifications/back.js +++ b/plugins/notifications/back.js @@ -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);