mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
fix duplicate notification
This commit is contained in:
@ -18,7 +18,7 @@ const notify = (info, options) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Send the notification
|
// Send the notification
|
||||||
currentNotification = new Notification(notification);
|
const currentNotification = new Notification(notification);
|
||||||
currentNotification.show()
|
currentNotification.show()
|
||||||
|
|
||||||
return currentNotification;
|
return currentNotification;
|
||||||
@ -27,11 +27,13 @@ const notify = (info, options) => {
|
|||||||
module.exports = (win, options) => {
|
module.exports = (win, options) => {
|
||||||
const registerCallback = getSongInfo(win);
|
const registerCallback = getSongInfo(win);
|
||||||
let oldNotification;
|
let oldNotification;
|
||||||
|
let oldTitle = "";
|
||||||
win.on("ready-to-show", () => {
|
win.on("ready-to-show", () => {
|
||||||
// Register the callback for new song information
|
// Register the callback for new song information
|
||||||
registerCallback(songInfo => {
|
registerCallback(songInfo => {
|
||||||
// If song is playing send notification
|
// If song is playing send notification
|
||||||
if (!songInfo.isPaused) {
|
if (!songInfo.isPaused && songInfo.title !== oldTitle) {
|
||||||
|
oldTitle = songInfo.title;
|
||||||
// Close the old notification
|
// Close the old notification
|
||||||
oldNotification?.close();
|
oldNotification?.close();
|
||||||
// This fixes a weird bug that would cause the notification to be updated instead of showing
|
// This fixes a weird bug that would cause the notification to be updated instead of showing
|
||||||
|
|||||||
Reference in New Issue
Block a user