🐛 fix(gtd): fix frozen object mutation in updateTodos (#11184)

* 🐛 fix(gtd): add console.log for updateTodos debugging

* 🐛 fix(gtd): fix frozen object mutation in updateTodos

* 🐛 fix(gtd): remove debug console.log
This commit is contained in:
Hardy
2026-01-04 16:09:43 +08:00
committed by GitHub
parent e61d9156b6
commit 4970794d1a

View File

@@ -151,13 +151,15 @@ class GTDExecutor extends BaseExecutor<typeof GTDApiNameEnum> {
}
case 'update': {
if (op.index !== undefined && op.index >= 0 && op.index < updatedTodos.length) {
const item = updatedTodos[op.index];
// Create a new object to avoid mutating frozen/immutable objects from store
const updatedItem = { ...updatedTodos[op.index] };
if (op.newText !== undefined) {
item.text = op.newText;
updatedItem.text = op.newText;
}
if (op.completed !== undefined) {
item.completed = op.completed;
updatedItem.completed = op.completed;
}
updatedTodos[op.index] = updatedItem;
results.push(`Updated item ${op.index + 1}`);
}
break;
@@ -171,7 +173,8 @@ class GTDExecutor extends BaseExecutor<typeof GTDApiNameEnum> {
}
case 'complete': {
if (op.index !== undefined && op.index >= 0 && op.index < updatedTodos.length) {
updatedTodos[op.index].completed = true;
// Create a new object to avoid mutating frozen/immutable objects from store
updatedTodos[op.index] = { ...updatedTodos[op.index], completed: true };
results.push(`Completed: "${updatedTodos[op.index].text}"`);
}
break;