chore(song-info): change from array to Set

change from `array` to `Set` to prevent the duplicate callback from being stored
This commit is contained in:
JellyBrick
2024-01-16 19:13:35 +09:00
parent 10f41bddad
commit 96d2a72bfa
2 changed files with 16 additions and 14 deletions

View File

@ -117,17 +117,19 @@ export const setUpTray = (app: Electron.App, win: Electron.BrowserWindow) => {
const trayMenu = Menu.buildFromTemplate(template);
tray.setContextMenu(trayMenu);
registerCallback(songInfo => {
if (typeof songInfo.isPaused === 'undefined') {
tray.setImage(defaultTrayIcon);
return;
registerCallback((songInfo) => {
if (tray) {
if (typeof songInfo.isPaused === 'undefined') {
tray.setImage(defaultTrayIcon);
return;
}
tray.setToolTip(t('main.tray.tooltip.with-song-info', {
artist: songInfo.artist,
title: songInfo.title,
}));
tray.setImage(songInfo.isPaused ? pausedTrayIcon : defaultTrayIcon);
}
tray.setToolTip(t('main.tray.tooltip.with-song-info', {
artist: songInfo.artist,
title: songInfo.title,
}));
tray.setImage(songInfo.isPaused ? pausedTrayIcon : defaultTrayIcon);
})
});
};