fixed response error, made sure completed task count does not exceed
This commit is contained in:
parent
4631b1f6a3
commit
a618891eb1
2 changed files with 10 additions and 1 deletions
|
|
@ -329,6 +329,7 @@ const configs = (function () {
|
||||||
"Try specifying the index of the incomplete task(s) {user}",
|
"Try specifying the index of the incomplete task(s) {user}",
|
||||||
clearTasksExceptBroadcaster:
|
clearTasksExceptBroadcaster:
|
||||||
"All tasks have been cleared except for the streamer's, {user}!",
|
"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",
|
adminDeleteTasks: "All of {mentioned}'s tasks have been deleted",
|
||||||
|
|
||||||
// Grouped by task completion responses
|
// Grouped by task completion responses
|
||||||
|
|
|
||||||
|
|
@ -1182,10 +1182,14 @@ function removeTask(username, task) {
|
||||||
|
|
||||||
// remove tasks from tasks array
|
// remove tasks from tasks array
|
||||||
for (const index of removedTaskIndex) {
|
for (const index of removedTaskIndex) {
|
||||||
tasks[username].todos.splice(index, 1);
|
// decrement totalTaskCount if task is not done
|
||||||
|
if (!tasks[username].todos[index].done) {
|
||||||
taskListMemory.totalTaskCount--;
|
taskListMemory.totalTaskCount--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks[username].todos.splice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
||||||
if (!scrolling) {
|
if (!scrolling) {
|
||||||
renderTaskListToDOM();
|
renderTaskListToDOM();
|
||||||
|
|
@ -2190,6 +2194,10 @@ function renderTaskListToDOM() {
|
||||||
totalTaskCount = taskListMemory.totalTaskCount;
|
totalTaskCount = taskListMemory.totalTaskCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (totalTaskCount < completedTasksCount) {
|
||||||
|
totalTaskCount = completedTasksCount;
|
||||||
|
}
|
||||||
|
|
||||||
document.querySelector(
|
document.querySelector(
|
||||||
".task-count"
|
".task-count"
|
||||||
).innerText = `${completedTasksCount}/${totalTaskCount}`;
|
).innerText = `${completedTasksCount}/${totalTaskCount}`;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue