mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 11:21:46 +00:00
add notification on unpause option
This commit is contained in:
@ -27,13 +27,21 @@ const notify = (info, options) => {
|
||||
module.exports = (win, options) => {
|
||||
const registerCallback = getSongInfo(win);
|
||||
let oldNotification;
|
||||
let oldTitle = "";
|
||||
let oldURL = "";
|
||||
win.on("ready-to-show", () => {
|
||||
// Register the callback for new song information
|
||||
registerCallback(songInfo => {
|
||||
// If song is playing && title isn't the same as last one - send notification
|
||||
if (!songInfo.isPaused && songInfo.title !== oldTitle) {
|
||||
oldTitle = songInfo.title;
|
||||
// on pause - reset url? and skip notification
|
||||
if (songInfo.isPaused) {
|
||||
//reset oldURL if unpause notification option is on
|
||||
if (options.unpauseNotification) {
|
||||
oldURL = "";
|
||||
}
|
||||
return;
|
||||
}
|
||||
// If url isn't the same as last one - send notification
|
||||
if (songInfo.url !== oldURL) {
|
||||
oldURL = songInfo.url;
|
||||
// Close the old notification
|
||||
oldNotification?.close();
|
||||
// This fixes a weird bug that would cause the notification to be updated instead of showing
|
||||
|
||||
Reference in New Issue
Block a user