mirror of
https://github.com/remvze/moodist.git
synced 2025-12-17 00:44:14 +00:00
fix: play sounds when starting timer if not already playing
This commit is contained in:
parent
58bf28bb24
commit
2e375ad40a
1 changed files with 3 additions and 0 deletions
|
|
@ -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 => {
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue