mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-04-21 11:26:15 +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) {
|
||||
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(
|
||||
|
||||
Reference in New Issue
Block a user