Fix interval end event trigger

This commit is contained in:
IamTheFij 2024-10-18 09:06:03 -07:00
parent 64ea47f42b
commit fefe9bb6aa

View File

@ -147,8 +147,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Handle timer update for each second // Handle timer update for each second
m.remaining -= time.Second m.remaining -= time.Second
if m.remaining < 0 { if m.remaining < 0 {
m.runCommands(m.onIntervalEnd)
if m.isFocus { if m.isFocus {
// Focus period ends, switch to break // Focus period ends, switch to break
m.isFocus = false m.isFocus = false
@ -162,6 +160,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Break ends, switch back to focus or next interval // Break ends, switch back to focus or next interval
m.isFocus = true m.isFocus = true
m.intervalNum++ m.intervalNum++
m.runCommands(m.onIntervalEnd)
if m.intervalNum > m.intervals { if m.intervalNum > m.intervals {
// All intervals completed // All intervals completed
return m, tea.Quit return m, tea.Quit