diff --git a/internal/pomodoro/pomodoro.go b/internal/pomodoro/pomodoro.go index 8228249..a7bcc00 100644 --- a/internal/pomodoro/pomodoro.go +++ b/internal/pomodoro/pomodoro.go @@ -42,7 +42,7 @@ func RunPomodoro() { // Work shared.State.Mode = "Work" - go timer.Start(pomodoroConfig.Work) + timer.StartAsync(pomodoroConfig.Work) if !waitForTimer(timer) { break } @@ -50,13 +50,13 @@ func RunPomodoro() { // Breaks if session < pomodoroConfig.Sessions { shared.State.Mode = "ShortBreak" - go timer.Start(pomodoroConfig.ShortBreak) + timer.StartAsync(pomodoroConfig.ShortBreak) if !waitForTimer(timer) { break } } else { // last phase, prepare for finish shared.State.Mode = "LongBreak" - go timer.Start(pomodoroConfig.LongBreak) + timer.StartAsync(pomodoroConfig.LongBreak) if !waitForTimer(timer) { break } diff --git a/internal/pomodoro/timer.go b/internal/pomodoro/timer.go index 09a50ee..11b1070 100644 --- a/internal/pomodoro/timer.go +++ b/internal/pomodoro/timer.go @@ -24,7 +24,12 @@ func (t Timer) Init() Timer { } } -// Start the timer +// Start the timer (goroutine) +func (t *Timer) StartAsync(duration int) { + go t.Start(duration) +} + +// Start the timer (blocking) func (t *Timer) Start(duration int) { tick := time.NewTicker(time.Second) for timeLeft := duration; timeLeft > 0; {