show number of upload failures

Massimo Melina committed Jan 16, 2023 at 14:26 UTC a3ed43d8fe002a8c956e7228b27073550593ed40
1 file changed +4 -4
frontend/src/upload.ts
+4 -4
@@ -46,7 +46,7 @@ export function showUpload() {
46
47 function Content(){
48 const [files, setFiles] = useState([] as File[])
49 - const { qs, done, doneByte, paused } = useSnapshot(uploadState)
49 + const { qs, done, doneByte, paused, errors } = useSnapshot(uploadState)
50 return h(FlexV, {},
51 h(Flex, { gap: '.5em', flexWrap: 'wrap', justifyContent: 'center', position: 'sticky', top: -4, background: 'var(--bg)', boxShadow: '0 3px 3px #000' },
52 h('button',{ onClick: () => selectFiles() }, "Add file(s)"),
@@ -75,7 +75,7 @@ export function showUpload() {
75 setFiles(files.filter(x => x !== f))
76 }
77 }),
78 - done > 0 && h('div', {}, `Finished ${done} files, ${formatBytes(doneByte)}`),
78 + h('div', {}, [done && `${done} finished (${formatBytes(doneByte)})`, errors && `${errors} failed`].filter(Boolean).join(' – ')),
79 qs.length > 0 && h('div', {},
80 h(Flex, { alignItems: 'center', justifyContent: 'center', borderTop: '1px dashed', padding: '.5em' },
81 "Queue",
@@ -180,9 +180,9 @@ function startUpload(f: File | undefined, to: string) {
180 reloadOnClose = false
181 }
182 }).catch(e => {
183 - if (e.code === e.ABORT_ERR) return
183 + if (e.code === 20) return // aborted
184 if (!uploadState.errors++)
185 - alertDialog(e).then()
185 + alertDialog("Upload error", 'error').then()
186 })
187 }
188