Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globalized the song info and song controls, and updated Touch Bar for it. #102

Merged
merged 7 commits into from
Jan 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplifies the notification plugin to use the globalized song info
  • Loading branch information
Sem Vissscher authored and Sem Vissscher committed Dec 21, 2020
commit 5bffdbd6285a6816749c467d6e912d14748f9959
18 changes: 0 additions & 18 deletions plugins/notifications/actions.js

This file was deleted.

38 changes: 18 additions & 20 deletions plugins/notifications/back.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
const { nativeImage, Notification } = require("electron");

const { listenAction } = require("../utils");
const { ACTIONS, CHANNEL } = require("./actions.js");
const {Notification} = require('electron');

function notify(info) {
let notificationImage = "assets/youtube-music.png";
let notificationImage = 'assets/youtube-music.png';

if (info.image) {
notificationImage = nativeImage.createFromDataURL(info.image);
notificationImage = info.image.resize({height: 256, width: 256});
}

// Fill the notification with content
const notification = {
title: info.title || "Playing",
title: info.title || 'Playing',
body: info.artist,
icon: notificationImage,
silent: true,
silent: true
};
// Send the notification
new Notification(notification).show();
}

function listenAndNotify() {
listenAction(CHANNEL, (event, action, imageSrc) => {
switch (action) {
case ACTIONS.NOTIFICATION:
notify(imageSrc);
break;
default:
console.log("Unknown action: " + action);
}
module.exports = win => {
win.on('ready-to-show', () => {
// Register the callback for new song information
global.songInfo.onNewData(songInfo => {
// If song is playing send notification
if (!songInfo.isPaused) {
notify(songInfo);
}
});
});
}

module.exports = listenAndNotify;
};
86 changes: 0 additions & 86 deletions plugins/notifications/front.js

This file was deleted.