From 29b633bcb4ccce1ca384ceb2b1cbf3a9998f845d Mon Sep 17 00:00:00 2001 From: cblte Date: Mon, 13 Jan 2025 21:18:10 +0100 Subject: [PATCH] Update index.ts promptComplete function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit .then(...) part: By passing "showCompleted" instead of "true", the function respects the user’s preference to hide or show completed tasks. This ensures that tasks already marked as completed and hidden remain so. To uncomplete these tasks, users would first need to display them and then use the “Mark as Complete” interface to modify their status. --- Chapter 02/todo/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter 02/todo/src/index.ts b/Chapter 02/todo/src/index.ts index 2fb9c28..78b8a95 100644 --- a/Chapter 02/todo/src/index.ts +++ b/Chapter 02/todo/src/index.ts @@ -43,7 +43,7 @@ function promptComplete(): void { ({name: item.task, value: item.id, checked: item.complete})) }).then(answers => { let completedTasks = answers["complete"] as number[]; - collection.getTodoItems(true).forEach(item => + collection.getTodoItems(showCompleted).forEach(item => collection.markComplete(item.id, completedTasks.find(id => id === item.id) != undefined)); promptUser();