Utkarshn10 / Focusly

Open source app to remain focused during your deep work sessions. Built using ReactJS
https://focusly.vercel.app/
MIT License
35 stars 44 forks source link

Timer behavior #111

Open Utkarshn10 opened 1 year ago

Utkarshn10 commented 1 year ago

Describe the bug Timer stops working when one sound is cancelled and another is played.

To Reproduce Steps to reproduce the behavior:

  1. Click on any card
  2. Click on the card after some time when the sound starts playing
  3. Click on another card

Expected behavior Timer should continue if the sound is playing

ayushichoudhary-19 commented 1 year ago

I would like to work on this issue.

Utkarshn10 commented 1 year ago

Hey @ayushichoudhary-19 I have assigned an issue to you. You can pick this one up after completing that one. Till then it's open for contributors.

Thanks

KaushikKundu commented 1 year ago

I would like to work on this issue.

Utkarshn10 commented 1 year ago

Issue assigned to @KaushikKundu. Thanks for contributing to Focusly :)

KaushikKundu commented 1 year ago

Hey @Utkarshn10 After thoroughly reviewing the code, I found the 'handlePause' and 'handleStart' functions and associated state changes a little confusing in the "focusSoundCard.js" file.

LIke, handlePause function is setting 'isPaused' state false, which is counterintuitive as it's pausing the timer. Also, in handleStart function 'isPaused' is set to true, but the timer is not paused.

Can you please explain their intended logic? I can modify but I'm afraid it might break the core logic of timer.

Utkarshn10 commented 1 year ago

Hey @KaushikKundu the intended aim of having handle pause was to handle the management of audio when the audio is paused (not closed), so that audio starts from where it was paused. While handle start takes care of audio being started and closed.

Note : by close here I mean when the user closes the card.

KaushikKundu commented 1 year ago

but I see, that in handleStart function, IsPaused is set to true, it also checks and starts the timer.
Specifically, why IsPaused is set to true here? const handleStart = () => { setIsActive(true); setIsPaused(true); if (timer === 0) { countRef.current = setInterval(() => { setTimer((timer) => timer + 1); }, 1000); } };

Utkarshn10 commented 1 year ago

I believe this line might be causing the issue of timer.

KaushikKundu commented 1 year ago

Yeah, guess so. I saw same kind of counterintuitive logic in other parts. Lets see if I can fix this.

Mohit-0918 commented 1 year ago

Hey @Utkarshn10 can you assign it to me i think i might fix this

adityaapurba commented 11 months ago

hey @Utkarshn10 i will solve it

Utkarshn10 commented 11 months ago

Hey @KaushikKundu are you working on this issue?

KaushikKundu commented 11 months ago

Hey @Utkarshn10 , I think it'd be better to unassign me for this issue. I tried but couldn't solve it completely.

Utkarshn10 commented 11 months ago

Hey @Mohit-0918 assigning this to you. Thanks