mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-10 18:21:47 +00:00
Backport missing changes for playlist badge
This commit is contained in:
@ -121,19 +121,21 @@ async function downloadPlaylist(givenUrl, win, options) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const steps = 1 / playlist.items.length;
|
|
||||||
let progress = 0;
|
|
||||||
|
|
||||||
win.setProgressBar(2); // starts with indefinite bar
|
win.setProgressBar(2); // starts with indefinite bar
|
||||||
|
|
||||||
|
let downloadCount = 0;
|
||||||
|
setBadge(playlist.items.length);
|
||||||
|
|
||||||
let dirWatcher = chokidar.watch(playlistFolder);
|
let dirWatcher = chokidar.watch(playlistFolder);
|
||||||
dirWatcher.on('add', () => {
|
dirWatcher.on('add', () => {
|
||||||
progress += steps;
|
downloadCount += 1;
|
||||||
if (progress >= 0.9999) {
|
if (downloadCount >= playlist.items.length) {
|
||||||
win.setProgressBar(-1); // close progress bar
|
win.setProgressBar(-1); // close progress bar
|
||||||
dirWatcher.close().then(() => dirWatcher = null);
|
setBadge(0); // close badge counter
|
||||||
|
dirWatcher.close().then(() => (dirWatcher = null));
|
||||||
} else {
|
} else {
|
||||||
win.setProgressBar(progress);
|
win.setProgressBar(downloadCount / playlist.items.length);
|
||||||
|
setBadge(playlist.items.length - downloadCount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user