Skip to content

Commit

Permalink
fix(status): clear message only if it is the intended one
Browse files Browse the repository at this point in the history
  • Loading branch information
idursun committed Mar 5, 2025
1 parent 74a2285 commit c68f30b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions internal/ui/status/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package status

import (
"fmt"
"time"

"github.com/charmbracelet/bubbles/help"
"github.com/charmbracelet/bubbles/spinner"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
"github.com/idursun/jjui/internal/ui/common"
"github.com/idursun/jjui/internal/ui/context"
"github.com/idursun/jjui/internal/ui/operations"
"time"
)

type Model struct {
Expand All @@ -33,7 +34,7 @@ var (
modeStyle = lipgloss.NewStyle().Inherit(normalStyle).Foreground(common.Black).Background(common.DarkBlue)
)

type clearMsg struct{}
type clearMsg string

func (m *Model) Width() int {
return m.width
Expand All @@ -55,9 +56,11 @@ func (m *Model) Init() tea.Cmd {
func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case clearMsg:
m.command = ""
m.error = nil
m.output = ""
if m.command == string(msg) {
m.command = ""
m.error = nil
m.output = ""
}
return m, nil
case common.CommandRunningMsg:
m.command = string(msg)
Expand All @@ -67,8 +70,9 @@ func (m *Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.running = false
m.output = msg.Output
m.error = msg.Err
commandToBeCleared := m.command
return m, tea.Tick(CommandClearDuration, func(time.Time) tea.Msg {
return clearMsg{}
return clearMsg(commandToBeCleared)
})
case operations.OperationChangedMsg:
m.op = msg.Operation
Expand Down

0 comments on commit c68f30b

Please sign in to comment.