From 855b7f4ad664a836557986745262e6bbe0ff64bd Mon Sep 17 00:00:00 2001 From: minsung Date: Mon, 12 Oct 2026 18:59:10 +0900 Subject: [PATCH] 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 --- src/App.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index b2af253..28261cc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -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