chore: cleanup pause/resume functions

This commit is contained in:
Sebastian Mark 2024-10-20 11:27:28 +02:00
parent b62e92b5a4
commit 3d5cb29c54
2 changed files with 9 additions and 6 deletions

View file

@ -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
}

View file

@ -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() {