perf(ui): update the download progress once per visible change

fetchWithProgress reports every network chunk; only re-render when the
"x MB / y MB" label actually changes (#1).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
minsungandClaude Opus 5.5 committed 2026-10-12 18:59:10 +09:00
1 parent 6533c31704
commit 855b7f4ad6
1 file changed
+5 -1
+5 -1
View File
@@ -152,10 +152,14 @@ export function App() {
let name: string
if (source.kind === "url") {
name = source.name ?? nameFromUrl(source.url)
let lastLabel = ""
buf = await fetchWithProgress(source.url, (loaded, total) => {
if (stale()) return
const size = total ? `${formatBytes(loaded)} / ${formatBytes(total)}` : formatBytes(loaded)
setLoadState({ label: `도면 내려받는 중 (${size})`, value: total ? Math.round(Math.min(1, loaded / total) * 50) : null, busy: true })
const label = `도면 내려받는 중 (${size})`
if (label === lastLabel) return // one update per visible change, not per network chunk
lastLabel = label
setLoadState({ label, value: total ? Math.round(Math.min(1, loaded / total) * 50) : null, busy: true })
})
} else {
name = source.file.name