feat: implement progress bar (os-level API) for getting favorites

This commit is contained in:
Xymorot 2021-01-05 03:14:36 +01:00
parent 9a7bd1d688
commit 597f9aaee0
1 changed files with 4 additions and 1 deletions

View File

@ -41,6 +41,7 @@ export class NhentaiAppWindow extends SiteAppWindow implements INhentaiAppWindow
await this.login();
}
this._window?.setProgressBar(0, { mode: 'indeterminate' });
const bookUrls: string[] = [];
for await (const wc of this.getFavoritePageWebContentsGenerator()) {
bookUrls.push(
@ -52,8 +53,10 @@ export class NhentaiAppWindow extends SiteAppWindow implements INhentaiAppWindow
const readable = Readable.from(
(async function* (thisArg): AsyncGenerator<IFavorite, undefined> {
for (const bookUrl of bookUrls) {
for (let i = 0; i < bookUrls.length; i++) {
const bookUrl = bookUrls[i];
yield await thisArg.getBookTorrent(bookUrl);
thisArg._window?.setProgressBar(i / bookUrls.length);
}
return;
})(this),