@@ 128,6 128,9 @@ func RoomTUI(client *mautrix.Client, roomID id.RoomID, elections *election.Elect
// user wants to create election (i == 0)
title, candidates := CreateElectionTUI()
+ if candidates == nil {
+ return
+ }
log.Debugf("title: %s", title)
log.Debugf("candidates: %s", candidates)
var err error
@@ 197,9 200,11 @@ func CreateElectionTUI() (title string, candidates []election.Candidate) {
n--
}
}
+ hitSubmit := false
done := func() {
// TODO: ensure none of the candidates are empty
app.Stop()
+ hitSubmit = true
title = form.GetFormItem(0).(*tview.InputField).GetText()
for i := 1; i <= n; i++ {
candidates = append(candidates,
@@ 216,6 221,10 @@ func CreateElectionTUI() (title string, candidates []election.Candidate) {
if err := app.SetRoot(form, true).SetFocus(form).Run(); err != nil {
panic(err)
}
+ if !hitSubmit {
+ // user didn't hit submit button; consider form incomplete
+ return "", nil
+ }
return title, candidates
}