fixed undone command
This commit is contained in:
parent
0627afee87
commit
4ccbe0f50d
1 changed files with 28 additions and 8 deletions
|
|
@ -262,7 +262,9 @@ function removeTask(username, task) {
|
||||||
if (isInt(t)) {
|
if (isInt(t)) {
|
||||||
index = parseInt(t) - 1; // ACTUAL INDEX
|
index = parseInt(t) - 1; // ACTUAL INDEX
|
||||||
} else if (incompleteTasks.length === 1) {
|
} else if (incompleteTasks.length === 1) {
|
||||||
index = tasks[username].todos.findIndex((t) => !t.done);
|
index = tasks[username].todos.findIndex(
|
||||||
|
(t) => !t.done
|
||||||
|
);
|
||||||
tasksRemoved.push(tasks[username].todos[index].text);
|
tasksRemoved.push(tasks[username].todos[index].text);
|
||||||
removedTaskIndex.push(index);
|
removedTaskIndex.push(index);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -401,8 +403,12 @@ function markTaskDone(username, task) {
|
||||||
if (isInt(t)) {
|
if (isInt(t)) {
|
||||||
index = parseInt(t) - 1; // ACTUAL INDEX
|
index = parseInt(t) - 1; // ACTUAL INDEX
|
||||||
} else if (incompleteTasks.length === 1) {
|
} else if (incompleteTasks.length === 1) {
|
||||||
index = tasks[username].todos.findIndex((t) => !t.done);
|
index = tasks[username].todos.findIndex(
|
||||||
tasksMarkedComplete.push(tasks[username].todos[index].text);
|
(t) => !t.done
|
||||||
|
);
|
||||||
|
tasksMarkedComplete.push(
|
||||||
|
tasks[username].todos[index].text
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
tasksFailedToComplete.push(t);
|
tasksFailedToComplete.push(t);
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -412,7 +418,9 @@ function markTaskDone(username, task) {
|
||||||
tasksFailedToComplete.push(t);
|
tasksFailedToComplete.push(t);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
tasksMarkedComplete.push(tasks[username].todos[index].text);
|
tasksMarkedComplete.push(
|
||||||
|
tasks[username].todos[index].text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tasksMarkedComplete.push(tasks[username].todos[index].text);
|
tasksMarkedComplete.push(tasks[username].todos[index].text);
|
||||||
|
|
@ -434,7 +442,7 @@ function markTaskDone(username, task) {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
let index = tasks[username].todos.findIndex(
|
let index = tasks[username].todos.findIndex(
|
||||||
(t) => t.text.toLowerCase() === task.toLowerCase()
|
(t) => t.text.toLowerCase() === task.toLowerCase() && !t.done
|
||||||
);
|
);
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
|
@ -526,7 +534,9 @@ function markTaskUndone(username, task) {
|
||||||
tasksFailedToMarkUndone.push(t);
|
tasksFailedToMarkUndone.push(t);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
tasksMarkedUndone.push(tasks[username].todos[index].text);
|
tasksMarkedUndone.push(
|
||||||
|
tasks[username].todos[index].text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tasksMarkedUndone.push(tasks[username].todos[index].text);
|
tasksMarkedUndone.push(tasks[username].todos[index].text);
|
||||||
|
|
@ -549,7 +559,7 @@ function markTaskUndone(username, task) {
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
let index = tasks[username].todos.findIndex(
|
let index = tasks[username].todos.findIndex(
|
||||||
(t) => t.text.toLowerCase() === task.toLowerCase()
|
(t) => t.text.toLowerCase() === task.toLowerCase() && t.done
|
||||||
);
|
);
|
||||||
|
|
||||||
if (index === -1) {
|
if (index === -1) {
|
||||||
|
|
@ -565,6 +575,16 @@ function markTaskUndone(username, task) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks[username].todos[index].done = false;
|
||||||
|
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
||||||
|
if (!scrolling) {
|
||||||
|
renderTaskListToDOM();
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
markedTasks: tasks[username].todos[index].text,
|
||||||
|
failedTasks: "",
|
||||||
|
};
|
||||||
|
} else {
|
||||||
tasks[username].todos[index].done = false;
|
tasks[username].todos[index].done = false;
|
||||||
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
localStorage.setItem(`tasks`, JSON.stringify(tasks));
|
||||||
if (!scrolling) {
|
if (!scrolling) {
|
||||||
|
|
@ -954,7 +974,7 @@ function cancelAnimation() {
|
||||||
secondaryAnimation.cancel();
|
secondaryAnimation.cancel();
|
||||||
}
|
}
|
||||||
scrolling = false;
|
scrolling = false;
|
||||||
console.log("animation cancelled");
|
// console.log("animation cancelled");
|
||||||
}
|
}
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue