diff --git a/src/components/DownloadTable.tsx b/src/components/DownloadTable.tsx index be8ed1a..c5ea225 100644 --- a/src/components/DownloadTable.tsx +++ b/src/components/DownloadTable.tsx @@ -35,7 +35,7 @@ export const DownloadTable: React.FC = ({ filter }) => { const [contextMenu, setContextMenu] = useState<{ x: number; y: number; id: string } | null>(null); const [selectedIds, setSelectedIds] = useState>(new Set()); const [lastSelectedId, setLastSelectedId] = useState(null); - const [sortConfig, setSortConfig] = useState<{ column: string; direction: 'asc' | 'desc' } | null>(null); + const [sortConfig, setSortConfig] = useState<{ column: string; direction: 'asc' | 'desc' } | null>({ column: 'Date Added', direction: 'desc' }); const [columnWidths, setColumnWidths] = useState(() => { try { const stored = JSON.parse(window.localStorage.getItem(COLUMN_WIDTHS_STORAGE_KEY) || 'null'); @@ -220,6 +220,12 @@ export const DownloadTable: React.FC = ({ filter }) => { }) : sortConfig ? [...filteredDownloads].sort((a, b) => { + const aUnfinished = a.status !== 'completed'; + const bUnfinished = b.status !== 'completed'; + + if (aUnfinished && !bUnfinished) return -1; + if (!aUnfinished && bUnfinished) return 1; + let comparison = 0; switch (sortConfig.column) { case 'File Name': @@ -443,11 +449,12 @@ export const DownloadTable: React.FC = ({ filter }) => {
{['File Name', 'Size', 'Status', 'Speed', 'ETA', 'Date Added'].map((label, index) => ( -
-
handleSort(label)} - > +
handleSort(label)} + > +
{label} {sortConfig?.column === label && ( sortConfig.direction === 'asc' ? :