fix: frontend: upload counters weren't reset with upload-dialog closed
Massimo Melina committed
Feb 24, 2023 at 15:06 UTC
13dbf8f5ab7f1e7a0579880911da5279759dac77
1 file changed
+10
-5
frontend/src/upload.ts
+10
-5
@@ -57,13 +57,17 @@ setInterval(() => {
57
let reloadOnClose = false
58
let uploadDialogIsOpen = false
59
60
+function resetCounters() {
61
+ Object.assign(uploadState, {
62
+ errors: 0,
63
+ done: 0,
64
+ doneByte: 0,
65
+ })
66
+}
67
+
68
export function showUpload() {
69
if (!uploadState.qs.length)
62
- Object.assign(uploadState, {
63
- errors: 0,
64
- done: 0,
65
- doneByte: 0,
66
- })
70
+ resetCounters()
71
uploadDialogIsOpen = true
72
const close = newDialog({
73
dialogProps: { style: { minWidth: 'min(20em, 100vw - 1em)' } },
@@ -313,6 +317,7 @@ async function startUpload(f: File, to: string, resume=0) {
317
reloadOnClose = false
318
if (!uploadDialogIsOpen)
319
alertDialog(h('div', {}, t`Upload terminated`, h('div', {}, h(UploadStatus))), 'info')
320
+ .finally(resetCounters)
321
}
322
}
323