Fix CPU use bug
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing

When I publish program level commands, they also come back around to my app causing it to
eat tons of CPU. Now I'm only publishing this when the state changes.
This commit is contained in:
IamTheFij 2024-10-24 15:54:30 -07:00
parent 631dc539f2
commit edaa60c13a

View File

@ -294,7 +294,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.state = "Focus" m.state = "Focus"
m.startCommands(m.onFocusStart) m.startCommands(m.onFocusStart)
cmds = append(cmds, tick()) cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)), tick())
case timeMsg: case timeMsg:
// Handle timer update for each second // Handle timer update for each second
@ -326,6 +326,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
// Run onFocusStart commands // Run onFocusStart commands
m.startCommands(m.onFocusStart) m.startCommands(m.onFocusStart)
} }
cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)))
} }
cmds = append(cmds, tick()) cmds = append(cmds, tick())
@ -335,8 +337,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.height = msg.Height m.height = msg.Height
} }
cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)))
// Get errors from shellrunner // Get errors from shellrunner
for { for {
result := m.shellrunner.GetResults() result := m.shellrunner.GetResults()