From 220290f6f0efcfb31b7c7cdab0e8b8dbfd9476d7 Mon Sep 17 00:00:00 2001 From: NimBold Date: Mon, 29 Jun 2026 21:30:30 +0330 Subject: [PATCH] fix(ui): apply initial progress state on mount to prevent 0% blink --- src/components/DownloadItem.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/components/DownloadItem.tsx b/src/components/DownloadItem.tsx index 970ce7c..5b231d2 100644 --- a/src/components/DownloadItem.tsx +++ b/src/components/DownloadItem.tsx @@ -55,10 +55,8 @@ export const DownloadItem = React.memo(({ useEffect(() => { if (!download || download.status !== 'downloading') return; - const unsubscribe = useDownloadProgressStore.subscribe((state) => { - const progress = state.progressMap[downloadId]; + const applyProgress = (progress: any) => { if (!progress) return; - if (progressBarRef.current) { progressBarRef.current.style.width = `${progress.fraction * 100}%`; } @@ -74,6 +72,13 @@ export const DownloadItem = React.memo(({ etaTextRef.current.innerText = progress.eta; etaTextRef.current.title = progress.eta; } + }; + + // Apply immediate state on mount + applyProgress(useDownloadProgressStore.getState().progressMap[downloadId]); + + const unsubscribe = useDownloadProgressStore.subscribe((state) => { + applyProgress(state.progressMap[downloadId]); }); return () => unsubscribe();