Use refactored providers in touchbar plugin

This commit is contained in:
TC
2021-01-12 21:17:40 +01:00
parent 0743034de0
commit 9110e79c16

View File

@ -7,6 +7,9 @@ const {
TouchBarScrubber, TouchBarScrubber,
} = TouchBar; } = TouchBar;
const getSongInfo = require("../../providers/song-info");
const getSongControls = require("../../providers/song-controls");
// Songtitle label // Songtitle label
const songTitle = new TouchBarLabel({ const songTitle = new TouchBarLabel({
label: "", 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 // If the page is ready, register the callback
win.on('ready-to-show', () => { win.on("ready-to-show", () => {
controls = [ controls = [previous, playPause, next, like, dislike];
global.songControls.previous,
global.songControls.pause,
global.songControls.next,
global.songControls.like,
global.songControls.dislike
];
// Register the callback // Register the callback
global.songInfo.onNewData(songInfo => { registerCallback((songInfo) => {
// Song information changed, so lets update the touchBar // Song information changed, so lets update the touchBar
// Set the song title // Set the song title