techstartucalgary/lifeline

Fix Course Deletion

Closed this issue · 4 comments

Deleting courses no longer works
Introduced in #255

Lifeline._.Making.Deadlines.Easier.-.Google.Chrome.2023-03-23.13-28-00.mp4

@cloudyyoung

}, [courseKeyURLParam]);

what is the reason for having courseKeyURLParam as a dependency here? (Deleting it fixes the issue)

@cloudyyoung

}, [courseKeyURLParam]);

what is the reason for having courseKeyURLParam as a dependency here? (Deleting it fixes the issue)

Seems like courseKeyURLParam was already there before #255 (didn't touch that line). But generally ESLint would want to have all the dependencies listed out on useEffect. So this triggers everytime the page route is changed.

When users delete a course, the localstorage is not updated (and only when they leave), it keeps reading from localstprage data where the course hasn't been deleted.

Since this useEffect is meant to trigger once for page render, simply wrap it in a useEffectOnce.

We should in general, optimize the "saving" technique a little bit. There could be a few reasons that user is risking to not have their data saved to localstorage properly, when the data is only saved when they leave the page:

  1. Browser crashes
  2. Browser force quits
  3. Browser hibernates inactive tabs

Without impact the performance too much, we should try to save data whenever data is changed. For example, save data on course deletion, assessment editing, etc.

We should in general, optimize the "saving" technique a little bit. There could be a few reasons that user is risking to not have their data saved to localstorage properly, when the data is only saved when they leave the page:

  1. Browser crashes
  2. Browser force quits
  3. Browser hibernates inactive tabs

Without impact the performance too much, we should try to save data whenever data is changed. For example, save data on course deletion, assessment editing, etc.

I'll add this to the fix