diff --git a/service/service.go b/service/service.go index ee1f7ea..b0b9a5d 100644 --- a/service/service.go +++ b/service/service.go @@ -70,8 +70,7 @@ func (s *Service) Run() { s.table.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { switch event.Rune() { case 'r', 'R': - s.fetchInstances() - s.updateTable() + s.refreshTable() return nil // case 's': @@ -90,6 +89,8 @@ func (s *Service) Run() { } func (s *Service) handleSelected(row int, col int) { + defer s.refreshTable() + cell := s.table.GetCell(row, col) ref := cell.GetReference() instance, ok := s.instances[ref.(string)] @@ -101,6 +102,11 @@ func (s *Service) handleSelected(row int, col int) { } } +func (s *Service) refreshTable() { + s.fetchInstances() + s.updateTable() +} + func (s *Service) ec2svc() { creds := credentials.NewChainCredentials( []credentials.Provider{