Skip to content

Commit

Permalink
Add notification when fields are empty when adding account
Browse files Browse the repository at this point in the history
  • Loading branch information
claucece committed Aug 22, 2017
1 parent 0f69bbf commit a58a5e2
Show file tree
Hide file tree
Showing 4 changed files with 508 additions and 492 deletions.
21 changes: 17 additions & 4 deletions gui/account_details.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,24 +253,30 @@ func (u *gtkUI) accountDialog(s access.Session, account *config.Account, saveFun
}
},
"on_save_signal": func() {
var err string

accTxt, _ := data.acc.GetText()
passTxt, _ := data.pass.GetText()
dispTxt, _ := data.displayName.GetText()
servTxt, _ := data.server.GetText()
portTxt, _ := data.port.GetText()

if len(accTxt) == 0 || len(passTxt) == 0 {
err = " Cannot add the account:\n\n" +
" Please, fill out the mandatory fields."
renderAccountAddError(data, err)
return
}

isJid, err := verifyXMPPAddress(accTxt)
if !isJid && failures > 0 {
failures++
return
}

if !isJid {
notification := buildBadUsernameNotification(err)
data.notificationArea.Add(notification)
notification.ShowAll()
renderAccountAddError(data, err)
failures++
log.Printf(err)
return
}

Expand Down Expand Up @@ -371,6 +377,13 @@ func (u *gtkUI) accountDialog(s access.Session, account *config.Account, saveFun
}
}

func renderAccountAddError(data *accountDetailsData, err string) {
notification := buildBadUsernameNotification(err)
data.notificationArea.Add(notification)
notification.ShowAll()
log.Printf(err)
}

func buildBadUsernameNotification(msg string) gtki.InfoBar {
assertInUIThread()
b := newBuilder("BadUsernameNotification")
Expand Down

0 comments on commit a58a5e2

Please sign in to comment.