chore: cleanup pause/resume functions
This commit is contained in:
parent
b62e92b5a4
commit
3d5cb29c54
2 changed files with 9 additions and 6 deletions
|
@ -70,10 +70,17 @@ func ResetPomodoro(clients map[*websocket.Conn]*models.Client) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func PausePomodoro() {
|
func PausePomodoro() {
|
||||||
|
mu.Lock()
|
||||||
|
pomodoroPaused = true
|
||||||
|
mu.Unlock()
|
||||||
|
|
||||||
pomodoroPauseChannel <- true
|
pomodoroPauseChannel <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResumePomodoro() {
|
func ResumePomodoro() {
|
||||||
|
mu.Lock()
|
||||||
|
pomodoroPaused = false
|
||||||
|
mu.Unlock()
|
||||||
pomodoroResumeChannel <- true
|
pomodoroResumeChannel <- true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,9 @@ func startTimer(clients map[*websocket.Conn]*models.Client, remainingSeconds int
|
||||||
case <-pomodoroResetChannel:
|
case <-pomodoroResetChannel:
|
||||||
return false
|
return false
|
||||||
case <-pomodoroPauseChannel:
|
case <-pomodoroPauseChannel:
|
||||||
mu.Lock()
|
// Nothing to set here, just waiting for the signal
|
||||||
pomodoroPaused = true
|
|
||||||
mu.Unlock()
|
|
||||||
case <-pomodoroResumeChannel:
|
case <-pomodoroResumeChannel:
|
||||||
mu.Lock()
|
// Nothing to set here, just waiting for the signal
|
||||||
pomodoroPaused = false
|
|
||||||
mu.Unlock()
|
|
||||||
default:
|
default:
|
||||||
// Broadcast the current state to all clients
|
// Broadcast the current state to all clients
|
||||||
if !IsPomodoroPaused() {
|
if !IsPomodoroPaused() {
|
||||||
|
|
Loading…
Reference in a new issue