Skip to content

Commit

Permalink
fix: play sounds when starting timer if not already playing
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMeepBoy committed Apr 28, 2024
1 parent 58bf28b commit 2e375ad
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/modals/sleep-timer/sleep-timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {

const timerId = useRef<NodeJS.Timeout>();

const isPlaying = useSoundStore(state => state.isPlaying);
const play = useSoundStore(state => state.play);
const pause = useSoundStore(state => state.pause);

const calculateTotalSeconds = useCallback((): number => {
Expand All @@ -36,6 +38,7 @@ export function SleepTimerModal({ onClose, show }: SleepTimerModalProps) {

const handleStart = () => {
if (timerId.current) clearInterval(timerId.current);
if (!isPlaying) play();

setTimeLeft(calculateTotalSeconds);
setRunning(true);
Expand Down

0 comments on commit 2e375ad

Please sign in to comment.