From a618891eb16d07cac038bf4453b0380cd46b546c Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Wed, 17 Jan 2024 13:31:02 +0800 Subject: [PATCH] fixed response error, made sure completed task count does not exceed --- configs.js | 1 + scripts/taskList.js | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/configs.js b/configs.js index bcd1bbf..981fefc 100644 --- a/configs.js +++ b/configs.js @@ -329,6 +329,7 @@ const configs = (function () { "Try specifying the index of the incomplete task(s) {user}", clearTasksExceptBroadcaster: "All tasks have been cleared except for the streamer's, {user}!", + clearedTasks: "All tasks have been cleared, {user}!", adminDeleteTasks: "All of {mentioned}'s tasks have been deleted", // Grouped by task completion responses diff --git a/scripts/taskList.js b/scripts/taskList.js index a3ac10d..e2f79c3 100644 --- a/scripts/taskList.js +++ b/scripts/taskList.js @@ -1182,8 +1182,12 @@ function removeTask(username, task) { // remove tasks from tasks array for (const index of removedTaskIndex) { + // decrement totalTaskCount if task is not done + if (!tasks[username].todos[index].done) { + taskListMemory.totalTaskCount--; + } + tasks[username].todos.splice(index, 1); - taskListMemory.totalTaskCount--; } localStorage.setItem(`tasks`, JSON.stringify(tasks)); @@ -2190,6 +2194,10 @@ function renderTaskListToDOM() { totalTaskCount = taskListMemory.totalTaskCount; } + if (totalTaskCount < completedTasksCount) { + totalTaskCount = completedTasksCount; + } + document.querySelector( ".task-count" ).innerText = `${completedTasksCount}/${totalTaskCount}`;