Focusly
Focusly copied to clipboard
Timer behavior
Describe the bug Timer stops working when one sound is cancelled and another is played.
To Reproduce Steps to reproduce the behavior:
- Click on any card
- Click on the card after some time when the sound starts playing
- Click on another card
Expected behavior Timer should continue if the sound is playing
I would like to work on this issue.
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
I would like to work on this issue.
Issue assigned to @KaushikKundu. Thanks for contributing to Focusly :)
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.
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.
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);
}
};
I believe this line might be causing the issue of timer.
Yeah, guess so. I saw same kind of counterintuitive logic in other parts. Lets see if I can fix this.
Hey @Utkarshn10 can you assign it to me i think i might fix this
hey @Utkarshn10 i will solve it
Hey @KaushikKundu are you working on this issue?
Hey @Utkarshn10 , I think it'd be better to unassign me for this issue. I tried but couldn't solve it completely.
Hey @Mohit-0918 assigning this to you. Thanks