Fixed recursive volume changes that caused cpu spike, Switched Repeat Modes to NONE|ONE|ALL

This commit is contained in:
David Metzler
2023-02-03 12:02:25 +01:00
parent a81476100b
commit 9da0e4305f
2 changed files with 27 additions and 9 deletions

View File

@ -67,14 +67,13 @@ function setupTimeChangeListener() {
}
function setupRepeatChangeListener() {
const mp = { NONE: "Repeat off", ONE: "Repeat one", ALL: "Repeat all" }
const repeatObserver = new MutationObserver(mutations => {
ipcRenderer.send('repeatChanged', mp[mutations[0].target.__dataHost.getState().queue.repeatMode])
ipcRenderer.send('repeatChanged', mutations[0].target.__dataHost.getState().queue.repeatMode)
});
repeatObserver.observe($('#right-controls .repeat'), {attributeFilter: ["title"]});
// Emit the initial value as well; as it's persistent between launches.
ipcRenderer.send('repeatChanged', mp[$('ytmusic-player-bar').getState().queue.repeatMode]);
ipcRenderer.send('repeatChanged', $('ytmusic-player-bar').getState().queue.repeatMode);
}
function setupVolumeChangeListener(api) {