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);
}
get length(): number {
return this.a.length;
}
values(): IterableIterator<T> {
return this.a.values();
}

View file

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