From edaa60c13aa2e4a8f3826cc08a277f8619832d6f Mon Sep 17 00:00:00 2001 From: Ian Fijolek Date: Thu, 24 Oct 2024 15:54:30 -0700 Subject: [PATCH] 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. --- main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 7496604..0d29ab0 100644 --- a/main.go +++ b/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()