More monior TUI refactor/cleanup
`tui/tui.go` is no longer responsible for passing window resize updates to all views, instead we request a new window size message to be sent at the same time we enter the view, allowing the view to catch and handle it. Add `Initialized` to `tui/shared/View` model, now we only call `Init` on a view before entering it for the first time, rather than calling `Init` on all views when the application starts. Renames file, small cleanups
This commit is contained in:
@@ -127,11 +127,6 @@ func (m Model) Init() tea.Cmd {
|
||||
return m.loadConversations()
|
||||
}
|
||||
|
||||
func (m *Model) HandleResize(width, height int) {
|
||||
m.Width, m.Height = width, height
|
||||
m.content.Width = width
|
||||
}
|
||||
|
||||
func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
var cmds []tea.Cmd
|
||||
switch msg := msg.(type) {
|
||||
@@ -139,7 +134,8 @@ func (m Model) Update(msg tea.Msg) (Model, tea.Cmd) {
|
||||
cmds = append(cmds, m.loadConversations())
|
||||
m.content.SetContent(m.renderConversationList())
|
||||
case tea.WindowSizeMsg:
|
||||
m.HandleResize(msg.Width, msg.Height)
|
||||
m.Width, m.Height = msg.Width, msg.Height
|
||||
m.content.Width = msg.Width
|
||||
m.content.SetContent(m.renderConversationList())
|
||||
case msgConversationsLoaded:
|
||||
m.App.Conversations = msg
|
||||
|
||||
Reference in New Issue
Block a user