henrylin03 / tasks

help you manage your to-dos
http://henrylin.io/tasks/
MIT License
0 stars 0 forks source link

bug: tasks from deleted project is orphaned and never actually makes it to inbox #41

Closed henrylin03 closed 3 months ago

henrylin03 commented 3 months ago

this blocks #28 and #31

steps to reproduce

  1. create a project called "delete this"
  2. in "delete this" add a task called "d1"
  3. in "delete this" add a task called "d2"
  4. (optional) add a task called "inbox task" in inbox
  5. WHEN we delete the project, "delete this", we EXPECT that both "d1" and "d2" will be shown in the "inbox", and "delete this" would be gone. if we check localStorage in DevTools > Application, we should also see that both tasks "d1" and "d2" should have projectId: "inbox", and no error messages in console.
  6. HOWEVER the tasks are still present in localStorage but orphaned (they never made it to inbox)

initial debugging attempts identified that although obj and type variables exist in modals/handleDelete.js module (where event listener for confirm delete button click in the modal is attached), by the time we call app.deleteProject(obj), obj still exists, but when we try and getTaskIds() it isn't actually getting the ids...

henrylin03 commented 3 months ago

_nb: the following applies only to NEWLY CREATED PROJECTS with NEWLY CREATED TASKS_

even though the project i'm trying to delete (called "de" here) has two tasks in the DOM: image

i will try other ways to resolve

henrylin03 commented 3 months ago

even though the project i'm trying to delete (called "de" here) has two tasks in the DOM: image

  • these are also in localStorage: image we see that the taskIds is actually empty in the object being passed to deleteProject() in appController: image

i will try other ways to resolve

if i trace this backwards...

displayProjectsInNav.js calls createProjectLinkInNav for every project object extracted using .getProjects() from appController, which reconstructs project after grabbing all project objects using localStorage helper function retrieveProjects()

henrylin03 commented 3 months ago

fixed in #42

key was that after we add a new task, we need to regenerate the nav bar links. otherwise, those nav project objects being retrieved don't have the latest tasks that you're adding to the project