diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index 0cf8514..c8a3b03 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -70,10 +70,17 @@ func ResetPomodoro(clients map[*websocket.Conn]*models.Client) { } func PausePomodoro() { + mu.Lock() + pomodoroPaused = true + mu.Unlock() + pomodoroPauseChannel <- true } func ResumePomodoro() { + mu.Lock() + pomodoroPaused = false + mu.Unlock() pomodoroResumeChannel <- true } diff --git a/internal/pomodoro/timer.go b/internal/pomodoro/timer.go index 69627c3..96595b3 100644 --- a/internal/pomodoro/timer.go +++ b/internal/pomodoro/timer.go @@ -14,13 +14,9 @@ func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int case <-pomodoroResetChannel: return false case <-pomodoroPauseChannel: - mu.Lock() - pomodoroPaused = true - mu.Unlock() + // Nothing to set here, just waiting for the signal case <-pomodoroResumeChannel: - mu.Lock() - pomodoroPaused = false - mu.Unlock() + // Nothing to set here, just waiting for the signal default: // Broadcast the current state to all clients if !IsPomodoroPaused() {