mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-22 21:30:44 +02:00
fix(upload): Prevent duplicate progress reports when using Promise.all (#908)
* fix(upload): Prevent duplicate progress reports when using Promise.all * fmt
This commit is contained in:
@@ -15,16 +15,17 @@ async function listenToEventIfNeeded(event: string): Promise<void> {
|
|||||||
if (listening) {
|
if (listening) {
|
||||||
return await Promise.resolve();
|
return await Promise.resolve();
|
||||||
}
|
}
|
||||||
return await appWindow
|
|
||||||
.listen<ProgressPayload>(event, ({ payload }) => {
|
// We're not awaiting this Promise to prevent issues with Promise.all
|
||||||
const handler = handlers.get(payload.id);
|
// the listener will still be registered in time.
|
||||||
if (handler != null) {
|
appWindow.listen<ProgressPayload>(event, ({ payload }) => {
|
||||||
handler(payload.progress, payload.total);
|
const handler = handlers.get(payload.id);
|
||||||
}
|
if (handler != null) {
|
||||||
})
|
handler(payload.progress, payload.total);
|
||||||
.then(() => {
|
}
|
||||||
listening = true;
|
});
|
||||||
});
|
|
||||||
|
listening = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function upload(
|
async function upload(
|
||||||
|
|||||||
Reference in New Issue
Block a user