From 9110e79c16d25a3fd1989d1839b758e661a4a9c2 Mon Sep 17 00:00:00 2001 From: TC Date: Tue, 12 Jan 2021 21:17:40 +0100 Subject: [PATCH] Use refactored providers in touchbar plugin --- plugins/touchbar/back.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/touchbar/back.js b/plugins/touchbar/back.js index 5eeba67f..87240ed0 100644 --- a/plugins/touchbar/back.js +++ b/plugins/touchbar/back.js @@ -7,6 +7,9 @@ const { TouchBarScrubber, } = TouchBar; +const getSongInfo = require("../../providers/song-info"); +const getSongControls = require("../../providers/song-controls"); + // Songtitle label const songTitle = new TouchBarLabel({ label: "", @@ -55,19 +58,16 @@ const touchBar = new TouchBar({ ], }); -module.exports = win => { +module.exports = (win) => { + const registerCallback = getSongInfo(win); + const { playPause, next, previous, like, dislike } = getSongControls(win); + // If the page is ready, register the callback - win.on('ready-to-show', () => { - controls = [ - global.songControls.previous, - global.songControls.pause, - global.songControls.next, - global.songControls.like, - global.songControls.dislike - ]; + win.on("ready-to-show", () => { + controls = [previous, playPause, next, like, dislike]; // Register the callback - global.songInfo.onNewData(songInfo => { + registerCallback((songInfo) => { // Song information changed, so lets update the touchBar // Set the song title