feat(downloads): inherit package selection visually

This commit is contained in:
Sucukdeluxe
2026-08-25 05:29:54 +02:00
parent afcc1fe782
commit ee66f1b3d9
2 changed files with 22 additions and 3 deletions
@@ -1,5 +1,6 @@
import { useEffect, useLayoutEffect, useMemo, useRef, useState, type CSSProperties, type ReactElement } from "react";
import { buildDownloadLogicalRows, type DownloadLogicalRow } from "./downloads-model";
import type { DownloadItem } from "../../../shared/types";
import { buildDownloadLogicalRows, type DownloadDisplayMode, type DownloadLogicalRow } from "./downloads-model";
import {
activateDownloadDisclosureTransition,
DOWNLOAD_DISCLOSURE_DURATION_MS,
@@ -78,19 +79,27 @@ function disclosureOpacity(row: DownloadLogicalRow | DownloadDisclosureRow): num
return "disclosureOpacity" in row && typeof row.disclosureOpacity === "number" ? row.disclosureOpacity : 1;
}
export function isDownloadItemVisuallySelected(
item: Pick<DownloadItem, "id" | "packageId">,
selectedIds: ReadonlySet<string>,
displayMode: DownloadDisplayMode
): boolean {
return selectedIds.has(item.id) || (displayMode === "packages" && selectedIds.has(item.packageId));
}
function renderVirtualRow(row: DownloadLogicalRow | DownloadDisclosureRow, model: DownloadsViewModel, actions: DownloadsViewActions): ReactElement {
if (row.type === "item-group") {
return (
<div className="downloads-disclosure-item-group">
{row.items.map((entry) => (
<ItemRow actions={actions} columnOrder={model.columnOrder} gridTemplate={model.gridTemplate} item={entry.item} key={entry.id} selected={model.selectedIds.has(entry.item.id)} sessionRunning={model.running} />
<ItemRow actions={actions} columnOrder={model.columnOrder} gridTemplate={model.gridTemplate} item={entry.item} key={entry.id} selected={isDownloadItemVisuallySelected(entry.item, model.selectedIds, model.displayMode)} sessionRunning={model.running} />
))}
</div>
);
}
if (row.type === "item") {
return (
<ItemRow actions={actions} columnOrder={model.columnOrder} gridTemplate={model.gridTemplate} item={row.item} selected={model.selectedIds.has(row.item.id)} sessionRunning={model.running} />
<ItemRow actions={actions} columnOrder={model.columnOrder} gridTemplate={model.gridTemplate} item={row.item} selected={isDownloadItemVisuallySelected(row.item, model.selectedIds, model.displayMode)} sessionRunning={model.running} />
);
}
return (