awstools: Fixed some bugs with the item view UI model
- The item view model is now being updated when the item itself is being updated - Fixed a NPE when the item view model receives a nil item
This commit is contained in:
parent
0f0bf70d01
commit
cc7ead496f
|
@ -60,10 +60,7 @@ func (c *CommandController) Alias(commandName string) Command {
|
|||
return events.SetError(errors.New("no such command: " + commandName))
|
||||
}
|
||||
|
||||
if len(args) > 1 {
|
||||
return command(args[1:])
|
||||
}
|
||||
return command([]string{})
|
||||
return command(args)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ type Model struct {
|
|||
|
||||
root tea.Model
|
||||
tableView *dynamotableview.Model
|
||||
itemView *dynamoitemview.Model
|
||||
}
|
||||
|
||||
func NewModel(rc *controllers.TableReadController, wc *controllers.TableWriteController, cc *commandctrl.CommandController) Model {
|
||||
|
@ -122,6 +123,7 @@ func NewModel(rc *controllers.TableReadController, wc *controllers.TableWriteCon
|
|||
tableSelect: tableSelect,
|
||||
root: root,
|
||||
tableView: dtv,
|
||||
itemView: div,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -132,7 +134,7 @@ func (m Model) Init() tea.Cmd {
|
|||
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case controllers.ResultSetUpdated:
|
||||
m.tableView.Refresh()
|
||||
return m, m.tableView.Refresh()
|
||||
case tea.KeyMsg:
|
||||
if !m.statusAndPrompt.InPrompt() && !m.tableSelect.Visible() {
|
||||
switch msg.String() {
|
||||
|
|
|
@ -85,6 +85,7 @@ func (m *Model) Resize(w, h int) layout.ResizingModel {
|
|||
func (m *Model) updateViewportToSelectedMessage() {
|
||||
if m.selectedItem == nil {
|
||||
m.viewport.SetContent("")
|
||||
return
|
||||
}
|
||||
|
||||
viewportContent := &strings.Builder{}
|
||||
|
|
|
@ -197,13 +197,13 @@ func (m *Model) selectedItem() (itemTableRow, bool) {
|
|||
func (m *Model) postSelectedItemChanged() tea.Msg {
|
||||
item, ok := m.selectedItem()
|
||||
if !ok {
|
||||
return nil
|
||||
return dynamoitemview.NewItemSelected{ResultSet: item.resultSet, Item: nil}
|
||||
}
|
||||
|
||||
return dynamoitemview.NewItemSelected{ResultSet: item.resultSet, Item: item.item}
|
||||
}
|
||||
|
||||
func (m *Model) Refresh() {
|
||||
|
||||
func (m *Model) Refresh() tea.Cmd {
|
||||
m.table.SetRows(m.rows)
|
||||
return m.postSelectedItemChanged
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue