From 79303d750ca298b53edb494d25b84fbcee0d8f4a Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Tue, 15 Aug 2023 19:43:55 +0800 Subject: [PATCH] updated taskList.js --- scripts/taskList.js | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/scripts/taskList.js b/scripts/taskList.js index 7e57823..2bd7545 100644 --- a/scripts/taskList.js +++ b/scripts/taskList.js @@ -299,7 +299,9 @@ function removeTask(username, task) { } localStorage.setItem(`tasks`, JSON.stringify(tasks)); - renderTaskListToDOM(); + if (!scrolling) { + renderTaskListToDOM(); + } return { removedTasks: tasksRemoved.join('", "'), failedTasks: tasksFailedToRemove.join('", "'), @@ -359,7 +361,9 @@ function clearOwnDoneTasks(username) { tasks[username].todos = incompleteUserTasks; localStorage.setItem(`tasks`, JSON.stringify(tasks)); - renderTaskListToDOM(); + if (!scrolling) { + renderTaskListToDOM(); + } return 1; } @@ -423,7 +427,9 @@ function markTaskDone(username, task) { } localStorage.setItem(`tasks`, JSON.stringify(tasks)); - renderTaskListToDOM(); + if (!scrolling) { + renderTaskListToDOM(); + } return { markedTasks: tasksMarkedComplete.join('", "'), failedTasks: tasksFailedToComplete.join('", "'), @@ -506,7 +512,9 @@ function editTask(username, message) { tasks[username].todos[index].text = newTask; localStorage.setItem(`tasks`, JSON.stringify(tasks)); - renderTaskListToDOM(); + if (!scrolling) { + renderTaskListToDOM(); + } return [originalTask, newTask]; } @@ -577,7 +585,6 @@ function clearAllDoneTasks() { tasks[user].todos = tasks[user].todos.filter((t) => !t.done); } cancelAnimation(); - scrolling = false; checkToAnimate(); localStorage.setItem(`tasks`, JSON.stringify(tasks)); renderTaskListToDOM(); @@ -586,7 +593,6 @@ function clearAllDoneTasks() { function clearAllTasks() { resetDB(); cancelAnimation(); - scrolling = false; checkToAnimate(); renderTaskListToDOM(); } @@ -605,7 +611,6 @@ function clearAllExceptStreamer(streamer) { clearAllDoneTasks(); cancelAnimation(); - scrolling = false; checkToAnimate(); renderTaskListToDOM(); @@ -680,11 +685,11 @@ async function tests1() { let listOfStreamers = [ `cloudydayzzz`, `berryspace`, - // `MohFocus`, - // `xeno_hiraeth`, - // `euphie___`, - // `unknownnie`, - // `theyolotato`, + `MohFocus`, + `xeno_hiraeth`, + `euphie___`, + `unknownnie`, + `theyolotato`, // `charliosaurus`, // `jutstreams`, // `mikewhatwhere`, @@ -701,6 +706,8 @@ async function tests1() { `task 1, task 2, task 3, task 4, task 5` ); await sleep(1000); + markTaskDone(listOfStreamers[i], `1, 2, 3, 4, 5`); + await sleep(1000); } } @@ -771,10 +778,13 @@ function cancelAnimation() { primaryAnimation.cancel(); secondaryAnimation.cancel(); } + scrolling = false; } (function () { - setupDB(); + // setupDB(); + resetDB(); + tests1(); importStyles(); renderTaskListToDOM(); })();