cms icon indicating copy to clipboard operation
cms copied to clipboard

The video completion tick-mark does not persist when the week section is re-opened

Open rayyan21d opened this issue 1 year ago • 5 comments

When I update the mark as complete check box, it doesn't persist when I close and reopen the week section.

image

To Reproduce Steps to reproduce the behavior:

  1. Open the website and log in
  2. Open a video and follow what the video does

Expected behavior The tick-mark should persist even if I close the week section.

Screenshots or GIFs

https://github.com/code100x/cms/assets/69739582/8093f50a-49ba-4ca8-948e-0250aebf7be3

Info (please complete the following information):

  • Browser Brave
  • Version: 1.65.132 Chromium: 124.0.6367.202 (Official Build) (64-bit)

Additional context

image

I checked the network tab and found ki request for updating the course is running and it's successful. But when I close and open the section, there's no network request that's going to load the data, or I'm not sure how the state is being saved. Maybe the state goes back to default values once the request is being sent.

rayyan21d avatar May 11 '24 16:05 rayyan21d

In this issue when refresh the website then it persiting the mark

shivam-raj03 avatar May 11 '24 19:05 shivam-raj03

I was thinking of using local storage to keep track of each checkbox's state.

useEffect(() => { localStorage.setItem( completed-${content.id}, JSON.stringify(completed), ); }, [completed]);

useEffect(() => { const savedCompleted = localStorage.getItem(completed-${content.id}); if (savedCompleted) { setCompleted(JSON.parse(savedCompleted)); } }, []);

This way , currently I'm setting up the project in my laptop, would like to send a pr if I get assigned. Cool!

jayprakash25 avatar May 12 '24 14:05 jayprakash25

Sorry, but the above solution isn't working and I figured out why we are facing this in the first place. The check component is being re-rendered when the accordion is opened or closed, causing the check state to be reset.

We can solve this by moving the check box state management to the parent Sidebar component, then we will pass the checkbox state and a function to update the checkbox state as a prop to the Check component.

jayprakash25 avatar May 12 '24 16:05 jayprakash25

https://www.loom.com/share/8fd99e679c7d4bf9b56612389e04e17e?t=10&sid=f908802e-e4f9-4755-b028-56b5ffafa7c0

And it's working!!!

jayprakash25 avatar May 12 '24 16:05 jayprakash25

When I update the mark as complete check box, it doesn't persist when I close and reopen the week section.

image

To Reproduce Steps to reproduce the behavior:

  1. Open the website and log in
  2. Open a video and follow what the video does

Expected behavior The tick-mark should persist even if I close the week section.

Screenshots or GIFs

out.4.mp4 Info (please complete the following information):

  • Browser Brave
  • Version: 1.65.132 Chromium: 124.0.6367.202 (Official Build) (64-bit)

Additional context

image

I checked the network tab and found ki request for updating the course is running and it's successful. But when I close and open the section, there's no network request that's going to load the data, or I'm not sure how the state is being saved. Maybe the state goes back to default values once the request is being sent.

Hey i'm also facing this issue, also after refreshing it is not getting checked. I'm using chrome

AbhimanyuAjudiya avatar May 19 '24 09:05 AbhimanyuAjudiya