Skip to content

Commit

Permalink
pam/model: Rename UsernameAndBrokerListReceived into UsernameSelected
Browse files Browse the repository at this point in the history
This event is now used by the user name selection model only and given
that we go in order by default it's not strictly needed to check again
for brokers availability
  • Loading branch information
3v1n0 committed Nov 8, 2024
1 parent 2352195 commit 9372736
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
11 changes: 4 additions & 7 deletions pam/internal/adapter/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ type UIModel struct {
// BrokerListReceived is received when we got the broker list.
type BrokerListReceived struct{}

// UsernameAndBrokerListReceived is received either when the user name is filled (pam or manually) and we got the broker list.
type UsernameAndBrokerListReceived struct{}
// UsernameSelected is received when the user name is filled (from pam or manually).
type UsernameSelected struct{}

// BrokerSelected signifies that the broker has been chosen.
type BrokerSelected struct {
Expand Down Expand Up @@ -180,14 +180,11 @@ func (m *UIModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
return m, m.userSelectionModel.SelectUser()

case UsernameAndBrokerListReceived:
log.Debugf(context.TODO(), "%#v, user: %q, brokers: %#v", msg, m.username(), m.availableBrokers())
case UsernameSelected:
log.Debugf(context.TODO(), "%#v, user: %q", msg, m.username())
if m.username() == "" {
return m, nil
}
if m.availableBrokers() == nil {
return m, nil
}

// Got user and brokers? Time to auto or manually select.
return m, AutoSelectForUser(m.Client, m.username())
Expand Down
2 changes: 1 addition & 1 deletion pam/internal/adapter/userselection.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (m userSelectionModel) Update(msg tea.Msg) (userSelectionModel, tea.Cmd) {
if !m.selected {
return m, nil
}
return m, sendEvent(UsernameAndBrokerListReceived{})
return m, sendEvent(UsernameSelected{})

case userRequired:
log.Debugf(context.TODO(), "%#v", msg)
Expand Down

0 comments on commit 9372736

Please sign in to comment.