fix (selection): disable selection for offline file

This commit is contained in:
MickaelK 2025-08-22 12:51:03 +10:00
parent 3fb8175b89
commit efedb54047
2 changed files with 9 additions and 14 deletions

View file

@ -101,20 +101,14 @@ function _selectionHelper(fn) {
continue;
}
const [basepath] = extractPath(curr.path);
if (!selections[i-1]) {
for (let j=0; j<=selections[i].n; j++) {
if (isSelected(j) === false) continue;
const file = selections[i].files[j];
set.add(basepath + file.name + (file.type === "directory" ? "/" : ""));
}
} else {
const min = Math.min(selections[i].n, selections[i-1]?.n || 0);
const max = Math.max(selections[i].n, selections[i-1]?.n || 0);
for (let j=min; j<=max; j++) {
if (isSelected(j) === false) continue;
const file = selections[i].files[j];
set.add(basepath + file.name + (file.type === "directory" ? "/" : ""));
}
const min = i === 0 ? 0 : Math.min(selections[i].n, selections[i-1].n);
const max = i === 0 ? selections[i].n : Math.max(selections[i].n, selections[i-1].n);
for (let j=min; j<=max; j++) {
if (isSelected(j) === false) continue;
const { offline, name, type } = selections[i].files[j];
if (offline === true) continue;
set.add(basepath + name + (type === "directory" ? "/" : ""));
}
}
return fn(set);

View file

@ -89,6 +89,7 @@ export function createThing({
$link.setAttribute("href", link);
if (location.search) $link.setAttribute("href", forwardURLParams(link, ["share", "canary", "tag"]));
$thing.setAttribute("data-droptarget", type === "directory");
$thing.setAttribute("data-selectable", !offline);
$thing.setAttribute("data-n", n);
$thing.setAttribute("data-path", path);
$thing.classList.add("view-" + view);