Fix removing todo items in node

After removal the index is wrong and I mistakely thought entries() adjuts.
This commit is contained in:
Simon Hausmann 2020-10-21 14:18:33 +02:00
parent f53997c155
commit 68e35ab332
2 changed files with 10 additions and 3 deletions

View file

@ -207,6 +207,10 @@ class ArrayModel<T> implements Model<T> {
this.notify.rowRemoved(index, size); this.notify.rowRemoved(index, size);
} }
get length(): number {
return this.a.length;
}
values(): IterableIterator<T> { values(): IterableIterator<T> {
return this.a.values(); return this.a.values();
} }

View file

@ -56,9 +56,12 @@ app.todo_added.setHandler(function (text) {
}) })
app.remove_done.setHandler(function () { app.remove_done.setHandler(function () {
for (const [i, item] of model.entries()) { let offset = 0;
if (item.checked) { const length = model.length;
model.remove(i, 1); for (let i = 0; i < length; ++i) {
if (model.rowData(i - offset).checked) {
model.remove(i - offset, 1);
offset++;
} }
} }
}) })