Cleaned up tui view switching
This commit is contained in:
@@ -24,7 +24,7 @@ type (
|
||||
// sent when conversation list is loaded
|
||||
msgConversationsLoaded ([]loadedConversation)
|
||||
// sent when a conversation is selected
|
||||
MsgConversationSelected models.Conversation
|
||||
msgConversationSelected models.Conversation
|
||||
)
|
||||
|
||||
type Model struct {
|
||||
@@ -51,7 +51,7 @@ func (m *Model) HandleInput(msg tea.KeyMsg) (bool, tea.Cmd) {
|
||||
case "enter":
|
||||
if len(m.conversations) > 0 && m.cursor < len(m.conversations) {
|
||||
return true, func() tea.Msg {
|
||||
return MsgConversationSelected(m.conversations[m.cursor].conv)
|
||||
return msgConversationSelected(m.conversations[m.cursor].conv)
|
||||
}
|
||||
}
|
||||
case "j", "down":
|
||||
@@ -121,6 +121,11 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
case msgConversationsLoaded:
|
||||
m.conversations = msg
|
||||
m.content.SetContent(m.renderConversationList())
|
||||
case msgConversationSelected:
|
||||
m.Values.ConvShortname = msg.ShortName.String
|
||||
cmds = append(cmds, func() tea.Msg {
|
||||
return shared.MsgViewChange(shared.StateChat)
|
||||
})
|
||||
}
|
||||
|
||||
var cmd tea.Cmd
|
||||
|
||||
Reference in New Issue
Block a user