Focusly icon indicating copy to clipboard operation
Focusly copied to clipboard

Timer behavior

Open Utkarshn10 opened this issue 1 year ago • 14 comments

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

Utkarshn10 avatar Sep 27 '23 14:09 Utkarshn10

I would like to work on this issue.

ayushichoudhary-19 avatar Sep 27 '23 21:09 ayushichoudhary-19

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

Utkarshn10 avatar Sep 28 '23 08:09 Utkarshn10

I would like to work on this issue.

KaushikKundu avatar Sep 30 '23 16:09 KaushikKundu

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

Utkarshn10 avatar Sep 30 '23 16:09 Utkarshn10

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.

KaushikKundu avatar Oct 01 '23 06:10 KaushikKundu

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.

Utkarshn10 avatar Oct 01 '23 06:10 Utkarshn10

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); } };

KaushikKundu avatar Oct 01 '23 07:10 KaushikKundu

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

Utkarshn10 avatar Oct 01 '23 08:10 Utkarshn10

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

KaushikKundu avatar Oct 01 '23 08:10 KaushikKundu

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

Mohit-0918 avatar Oct 03 '23 08:10 Mohit-0918

hey @Utkarshn10 i will solve it

adityaapurba avatar Oct 24 '23 17:10 adityaapurba

Hey @KaushikKundu are you working on this issue?

Utkarshn10 avatar Oct 24 '23 17:10 Utkarshn10

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

KaushikKundu avatar Oct 25 '23 04:10 KaushikKundu

Hey @Mohit-0918 assigning this to you. Thanks

Utkarshn10 avatar Oct 25 '23 06:10 Utkarshn10