Push raw indexes

This commit is contained in:
Nils Maier 2019-10-11 15:41:42 +02:00
parent 4ba827fc15
commit 1370723e6d
2 changed files with 6 additions and 4 deletions

View File

@ -14,6 +14,7 @@ import { windows, CHROME } from "./browser";
import { BaseItem } from "./item"; import { BaseItem } from "./item";
interface BaseMatchedItem extends BaseItem { interface BaseMatchedItem extends BaseItem {
sidx?: number;
matched?: string | null; matched?: string | null;
prevMatched?: string | null; prevMatched?: string | null;
} }
@ -29,6 +30,7 @@ function computeSelection(
onlyFast: boolean): ItemDelta[] { onlyFast: boolean): ItemDelta[] {
let ws = items.map((item, idx: number) => { let ws = items.map((item, idx: number) => {
item.idx = item.idx || idx; item.idx = item.idx || idx;
item.sidx = item.sidx || idx;
const {matched = null} = item; const {matched = null} = item;
item.prevMatched = matched; item.prevMatched = matched;
item.matched = null; item.matched = null;
@ -52,7 +54,7 @@ function computeSelection(
} }
return items.filter(item => item.prevMatched !== item.matched).map(item => { return items.filter(item => item.prevMatched !== item.matched).map(item => {
return { return {
idx: item.idx, idx: item.sidx as number,
matched: item.matched matched: item.matched
}; };
}); });

View File

@ -138,7 +138,7 @@ class ItemCollection {
constructor(items: BaseMatchedItem[]) { constructor(items: BaseMatchedItem[]) {
this.items = items; this.items = items;
this.assignRows(); this.assignRows();
this.indexes = new Map(items.map(i => [i.idx, i])); this.indexes = new Map(items.map((i, idx) => [idx, i]));
} }
assignRows() { assignRows() {
@ -161,9 +161,9 @@ class ItemCollection {
get checkedIndexes() { get checkedIndexes() {
const rv: number[] = []; const rv: number[] = [];
this.items.forEach(function (item) { this.items.forEach(function(item, idx) {
if (item.matched && item.matched !== "unmanual") { if (item.matched && item.matched !== "unmanual") {
rv.push(item.idx); rv.push(idx);
} }
}); });
return rv; return rv;