Cleaned up tui view switching
This commit is contained in:
@@ -91,21 +91,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
m.state = shared.View(msg)
|
||||
switch m.state {
|
||||
case shared.StateChat:
|
||||
m.chat.HandleResize(m.State.Width, m.State.Height)
|
||||
m.chat.HandleResize(m.Width, m.Height)
|
||||
case shared.StateConversations:
|
||||
m.conversations.HandleResize(m.State.Width, m.State.Height)
|
||||
m.conversations.HandleResize(m.Width, m.Height)
|
||||
}
|
||||
return m, func() tea.Msg { return shared.MsgViewEnter(struct{}{}) }
|
||||
case conversations.MsgConversationSelected:
|
||||
// passed up through conversation list model
|
||||
m.State.Values.ConvShortname = msg.ShortName.String
|
||||
cmds = append(cmds, func() tea.Msg {
|
||||
return shared.MsgViewChange(shared.StateChat)
|
||||
})
|
||||
case tea.WindowSizeMsg:
|
||||
m.State.Width, m.State.Height = msg.Width, msg.Height
|
||||
case shared.MsgError:
|
||||
m.State.Err = msg
|
||||
m.Width, m.Height = msg.Width, msg.Height
|
||||
}
|
||||
|
||||
var cmd tea.Cmd
|
||||
@@ -123,18 +115,13 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
}
|
||||
|
||||
func (m Model) View() string {
|
||||
if m.State.Width == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
switch m.state {
|
||||
case shared.StateConversations:
|
||||
return m.conversations.View()
|
||||
case shared.StateChat:
|
||||
return m.chat.View()
|
||||
default:
|
||||
return ""
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func Launch(ctx *lmcli.Context, convShortname string) error {
|
||||
|
||||
Reference in New Issue
Block a user