Fix CPU use bug
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:
parent
631dc539f2
commit
edaa60c13a
6
main.go
6
main.go
@ -294,7 +294,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.state = "Focus"
|
||||
m.startCommands(m.onFocusStart)
|
||||
|
||||
cmds = append(cmds, tick())
|
||||
cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)), tick())
|
||||
|
||||
case timeMsg:
|
||||
// Handle timer update for each second
|
||||
@ -326,6 +326,8 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
// Run onFocusStart commands
|
||||
m.startCommands(m.onFocusStart)
|
||||
}
|
||||
|
||||
cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)))
|
||||
}
|
||||
|
||||
cmds = append(cmds, tick())
|
||||
@ -335,8 +337,6 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.height = msg.Height
|
||||
}
|
||||
|
||||
cmds = append(cmds, tea.SetWindowTitle(fmt.Sprintf("Gomodoro - %s", m.state)))
|
||||
|
||||
// Get errors from shellrunner
|
||||
for {
|
||||
result := m.shellrunner.GetResults()
|
||||
|
Loading…
Reference in New Issue
Block a user