Sort active packages by completion percentage, not absolute count
Some checks are pending
Build and Release / build (push) Waiting to run

1/6 (16.7%) now ranks above 5/153 (3.3%) since it's further along.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sucukdeluxe 2026-03-02 14:03:43 +01:00
parent 10b4f18d33
commit a9c8ee2ff4
2 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "real-debrid-downloader", "name": "real-debrid-downloader",
"version": "1.4.86", "version": "1.4.87",
"description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)", "description": "Real-Debrid Downloader Desktop (Electron + React + TypeScript)",
"main": "build/main/main/main.js", "main": "build/main/main/main.js",
"author": "Sucukdeluxe", "author": "Sucukdeluxe",

View File

@ -688,14 +688,14 @@ export function App(): ReactElement {
if (active.length === 0 || active.length === packages.length) { if (active.length === 0 || active.length === packages.length) {
return packages; return packages;
} }
// Sort active packages: most progress first (completed items, then downloaded bytes) // Sort active packages: highest completion percentage first
active.sort((a, b) => { active.sort((a, b) => {
const aItems = a.itemIds.map((id) => snapshot.session.items[id]).filter(Boolean); const aItems = a.itemIds.map((id) => snapshot.session.items[id]).filter(Boolean);
const bItems = b.itemIds.map((id) => snapshot.session.items[id]).filter(Boolean); const bItems = b.itemIds.map((id) => snapshot.session.items[id]).filter(Boolean);
const aCompleted = aItems.filter((i) => i.status === "completed").length; const aPct = aItems.length > 0 ? aItems.filter((i) => i.status === "completed").length / aItems.length : 0;
const bCompleted = bItems.filter((i) => i.status === "completed").length; const bPct = bItems.length > 0 ? bItems.filter((i) => i.status === "completed").length / bItems.length : 0;
if (aCompleted !== bCompleted) { if (aPct !== bPct) {
return bCompleted - aCompleted; return bPct - aPct;
} }
const aBytes = aItems.reduce((s, i) => s + (i.downloadedBytes || 0), 0); const aBytes = aItems.reduce((s, i) => s + (i.downloadedBytes || 0), 0);
const bBytes = bItems.reduce((s, i) => s + (i.downloadedBytes || 0), 0); const bBytes = bItems.reduce((s, i) => s + (i.downloadedBytes || 0), 0);