Skip to content

Commit

Permalink
Fix UI mess on separate download
Browse files Browse the repository at this point in the history
  • Loading branch information
Xwilarg committed Nov 6, 2022
1 parent 17e3588 commit 9d661cf
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/background/Downloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,21 @@ export default class Downloader
this.updateProgress(0, "in progress...", true);

let self = this;
this.#zip.generateAsync({type: "blob"}, function(elem: any) {
try {
self.updateProgress(elem.percent, elem.currentFile == null ? self.path : elem.currentFile, true);
} catch (e) { } // Dead object
})
.then(function(content: any) { // Zipping done
self.currentProgress = 100;
fileSaver.saveAs(content, self.downloadName + "." + self.useZip);
try {
self.updateProgress(100, null, true); // Notify popup that we are done
} catch (e) { } // Dead object
await new Promise((resolve, _reject) => {
resolve(
this.#zip.generateAsync({ type: "blob" }, function (elem: any) {
try {
self.updateProgress(elem.percent, elem.currentFile == null ? self.path : elem.currentFile, true);
} catch (e) { } // Dead object
})
.then(function (content: any) { // Zipping done
self.currentProgress = 100;
fileSaver.saveAs(content, self.downloadName + "." + self.useZip);
try {
self.updateProgress(100, null, true); // Notify popup that we are done
} catch (e) { } // Dead object
})
);
});
} else {
this.currentProgress = 100;
Expand Down

0 comments on commit 9d661cf

Please sign in to comment.