updated taskList.js, fixed no return bugs

This commit is contained in:
liyunze 2023-08-15 22:23:27 +08:00
parent 79303d750c
commit 601a81c38b

View file

@ -236,12 +236,12 @@ function addTask(username, userColor, task) {
// removed task: success
function removeTask(username, task) {
const tasks = JSON.parse(localStorage.tasks);
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
if (!tasks[username] || tasks[username].todos.length === 0) {
return 0;
}
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
// match regex: integers separated by space e.g. '1 2 3 4'
if (task.match(/^(\d+ )*\d+$/)) {
// insert commas between integers
@ -373,13 +373,14 @@ function clearOwnDoneTasks(username) {
// task: succcess
function markTaskDone(username, task) {
const tasks = JSON.parse(localStorage.tasks);
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
// user does not have any tasks
if (!tasks[username] || tasks[username].todos.length === 0) {
return 0;
}
const incompleteTasks = tasks[username].todos.filter((t) => !t.done);
// match regex: integers separated by space e.g. '1 2 3 4'
if (task.match(/^(\d+ )*\d+$/)) {
// insert commas between integers
@ -782,9 +783,7 @@ function cancelAnimation() {
}
(function () {
// setupDB();
resetDB();
tests1();
setupDB();
importStyles();
renderTaskListToDOM();
})();