fix(upload): Prevent duplicate progress reports when using Promise.all (#908)

* fix(upload): Prevent duplicate progress reports when using Promise.all

* fmt
pull/910/head
Fabian-Lars 1 year ago committed by GitHub
parent 83f9899f78
commit cf00900298
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -15,16 +15,17 @@ async function listenToEventIfNeeded(event: string): Promise<void> {
if (listening) {
return await Promise.resolve();
}
return await appWindow
.listen<ProgressPayload>(event, ({ payload }) => {
const handler = handlers.get(payload.id);
if (handler != null) {
handler(payload.progress, payload.total);
}
})
.then(() => {
listening = true;
});
// We're not awaiting this Promise to prevent issues with Promise.all
// the listener will still be registered in time.
appWindow.listen<ProgressPayload>(event, ({ payload }) => {
const handler = handlers.get(payload.id);
if (handler != null) {
handler(payload.progress, payload.total);
}
});
listening = true;
}
async function upload(

Loading…
Cancel
Save