Do not mess up queue when sorting in select

Closes #181
This commit is contained in:
Nils Maier 2019-10-28 11:13:19 +01:00
parent d3b7032229
commit e549886532

View File

@ -50,6 +50,7 @@ let Subfolder: Dropdown;
type DELTAS = {deltaLinks: ItemDelta[]; deltaMedia: ItemDelta[]}; type DELTAS = {deltaLinks: ItemDelta[]; deltaMedia: ItemDelta[]};
interface BaseMatchedItem extends BaseItem { interface BaseMatchedItem extends BaseItem {
backIdx: number;
matched?: string | null; matched?: string | null;
rowid: number; rowid: number;
} }
@ -138,6 +139,7 @@ class ItemCollection {
constructor(items: BaseMatchedItem[]) { constructor(items: BaseMatchedItem[]) {
this.items = items; this.items = items;
this.assignRows(); this.assignRows();
this.items.forEach((item, idx) => item.backIdx = idx);
this.indexes = new Map(items.map((i, idx) => [idx, i])); this.indexes = new Map(items.map((i, idx) => [idx, i]));
} }
@ -159,11 +161,11 @@ class ItemCollection {
return rv; return rv;
} }
get checkedIndexes() { get checkedBackIndexes() {
const rv: number[] = []; const rv: number[] = [];
this.items.forEach(function(item, idx) { this.items.forEach(function(item) {
if (item.matched && item.matched !== "unmanual") { if (item.matched && item.matched !== "unmanual") {
rv.push(idx); rv.push(item.backIdx);
} }
}); });
return rv; return rv;
@ -679,7 +681,7 @@ async function download(paused = false) {
const subfolder = Subfolder.value; const subfolder = Subfolder.value;
validateSubfolder(subfolder); validateSubfolder(subfolder);
const items = Table.items.checkedIndexes; const items = Table.items.checkedBackIndexes;
if (!items.length) { if (!items.length) {
throw new Error("error.noItemsSelected"); throw new Error("error.noItemsSelected");
} }