tui: fixed Init handling
Don't re-init components on each state change
This commit is contained in:
parent
39cd4227c6
commit
9e6d41a3ff
@ -218,8 +218,6 @@ func (m chatModel) Update(msg tea.Msg) (chatModel, tea.Cmd) {
|
||||
var cmds []tea.Cmd
|
||||
switch msg := msg.(type) {
|
||||
case msgChangeState:
|
||||
cmds = append(cmds, m.Init())
|
||||
|
||||
if m.opts.convShortname != "" && m.conversation.ShortName.String != m.opts.convShortname {
|
||||
cmds = append(cmds, m.loadConversation(m.opts.convShortname))
|
||||
}
|
||||
|
@ -77,9 +77,13 @@ func initialModel(ctx *lmcli.Context, opts Options) model {
|
||||
}
|
||||
|
||||
func (m model) Init() tea.Cmd {
|
||||
return func() tea.Msg {
|
||||
return tea.Batch(
|
||||
m.conversations.Init(),
|
||||
m.chat.Init(),
|
||||
func() tea.Msg {
|
||||
return msgChangeState(m.state)
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func (m *model) handleGlobalInput(msg tea.KeyMsg) (bool, tea.Cmd) {
|
||||
|
Loading…
Reference in New Issue
Block a user