Merge pull request #37 from yusufipk/worktree-fix-download-notice

feat(downloads): let the download progress toast be minimized
This commit is contained in:
Yusuf İpek
2026-07-25 12:59:18 +03:00
committed by GitHub
4 changed files with 195 additions and 26 deletions
+9 -2
View File
@@ -40,10 +40,17 @@ export function formatBytes(bytes: number): string {
return `${(mb / 1024).toFixed(2)} GB`;
}
/** Percentage done, or null when the server didn't send a Content-Length. */
export function downloadProgressPercent(progress: DownloadProgress): number | null {
const { receivedBytes, totalBytes } = progress;
if (!totalBytes || totalBytes <= 0) return null;
return Math.min(100, Math.floor((receivedBytes / totalBytes) * 100));
}
export function downloadProgressLabel(progress: DownloadProgress): string {
const { receivedBytes, totalBytes } = progress;
if (totalBytes && totalBytes > 0) {
const pct = Math.min(100, Math.floor((receivedBytes / totalBytes) * 100));
const pct = downloadProgressPercent(progress);
if (pct !== null && totalBytes) {
return `${pct}% · ${formatBytes(receivedBytes)} / ${formatBytes(totalBytes)}`;
}
return formatBytes(receivedBytes);