updated taskList.js

This commit is contained in:
liyunze 2023-08-15 19:43:55 +08:00
parent fd51dbdca0
commit 79303d750c

View file

@ -299,7 +299,9 @@ function removeTask(username, task) {
} }
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM(); renderTaskListToDOM();
}
return { return {
removedTasks: tasksRemoved.join('", "'), removedTasks: tasksRemoved.join('", "'),
failedTasks: tasksFailedToRemove.join('", "'), failedTasks: tasksFailedToRemove.join('", "'),
@ -359,7 +361,9 @@ function clearOwnDoneTasks(username) {
tasks[username].todos = incompleteUserTasks; tasks[username].todos = incompleteUserTasks;
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM(); renderTaskListToDOM();
}
return 1; return 1;
} }
@ -423,7 +427,9 @@ function markTaskDone(username, task) {
} }
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM(); renderTaskListToDOM();
}
return { return {
markedTasks: tasksMarkedComplete.join('", "'), markedTasks: tasksMarkedComplete.join('", "'),
failedTasks: tasksFailedToComplete.join('", "'), failedTasks: tasksFailedToComplete.join('", "'),
@ -506,7 +512,9 @@ function editTask(username, message) {
tasks[username].todos[index].text = newTask; tasks[username].todos[index].text = newTask;
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
if (!scrolling) {
renderTaskListToDOM(); renderTaskListToDOM();
}
return [originalTask, newTask]; return [originalTask, newTask];
} }
@ -577,7 +585,6 @@ function clearAllDoneTasks() {
tasks[user].todos = tasks[user].todos.filter((t) => !t.done); tasks[user].todos = tasks[user].todos.filter((t) => !t.done);
} }
cancelAnimation(); cancelAnimation();
scrolling = false;
checkToAnimate(); checkToAnimate();
localStorage.setItem(`tasks`, JSON.stringify(tasks)); localStorage.setItem(`tasks`, JSON.stringify(tasks));
renderTaskListToDOM(); renderTaskListToDOM();
@ -586,7 +593,6 @@ function clearAllDoneTasks() {
function clearAllTasks() { function clearAllTasks() {
resetDB(); resetDB();
cancelAnimation(); cancelAnimation();
scrolling = false;
checkToAnimate(); checkToAnimate();
renderTaskListToDOM(); renderTaskListToDOM();
} }
@ -605,7 +611,6 @@ function clearAllExceptStreamer(streamer) {
clearAllDoneTasks(); clearAllDoneTasks();
cancelAnimation(); cancelAnimation();
scrolling = false;
checkToAnimate(); checkToAnimate();
renderTaskListToDOM(); renderTaskListToDOM();
@ -680,11 +685,11 @@ async function tests1() {
let listOfStreamers = [ let listOfStreamers = [
`cloudydayzzz`, `cloudydayzzz`,
`berryspace`, `berryspace`,
// `MohFocus`, `MohFocus`,
// `xeno_hiraeth`, `xeno_hiraeth`,
// `euphie___`, `euphie___`,
// `unknownnie`, `unknownnie`,
// `theyolotato`, `theyolotato`,
// `charliosaurus`, // `charliosaurus`,
// `jutstreams`, // `jutstreams`,
// `mikewhatwhere`, // `mikewhatwhere`,
@ -701,6 +706,8 @@ async function tests1() {
`task 1, task 2, task 3, task 4, task 5` `task 1, task 2, task 3, task 4, task 5`
); );
await sleep(1000); await sleep(1000);
markTaskDone(listOfStreamers[i], `1, 2, 3, 4, 5`);
await sleep(1000);
} }
} }
@ -771,10 +778,13 @@ function cancelAnimation() {
primaryAnimation.cancel(); primaryAnimation.cancel();
secondaryAnimation.cancel(); secondaryAnimation.cancel();
} }
scrolling = false;
} }
(function () { (function () {
setupDB(); // setupDB();
resetDB();
tests1();
importStyles(); importStyles();
renderTaskListToDOM(); renderTaskListToDOM();
})(); })();