Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
hirenko-v authored Sep 20, 2024
1 parent c0ce9c7 commit 06c42dc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/msg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func showBothSelects(firstSelection, secondSelection string) executor.ExecuteOut
}

// Clear second selection if the first selection has changed
var secondSelectGenerated bool
if firstSelection != "" {
// Run the script to get dynamic options based on the first selection
scriptOutput, err := runScript(firstSelection)
Expand Down Expand Up @@ -253,12 +254,18 @@ func showBothSelects(firstSelection, secondSelection string) executor.ExecuteOut
Options: dropdownOptions,
},
},
// Set secondSelection to "" after first is changed
InitialOption: &api.OptionItem{
Name: secondSelection,
Value: secondSelection,
},
})
secondSelectGenerated = true
}
}

// Only add the button if both selections are made
if firstSelection != "" && secondSelection != "" {
if firstSelection != "" && secondSelectGenerated && secondSelection != "" {
code := fmt.Sprintf("run %s %s", firstSelection, secondSelection)
sections = append(sections, api.Section{
Base: api.Base{
Expand All @@ -285,6 +292,7 @@ func showBothSelects(firstSelection, secondSelection string) executor.ExecuteOut
}



func (MsgExecutor) Help(context.Context) (api.Message, error) {
msg := description
msg += fmt.Sprintf("\nJust type `%s %s`", api.MessageBotNamePlaceholder, pluginName)
Expand Down

0 comments on commit 06c42dc

Please sign in to comment.