chore: minor change

This commit is contained in:
Adrien Waksberg 2019-10-20 15:14:21 +02:00
parent 9413df0cd3
commit 00336289c4

View file

@ -142,7 +142,7 @@ func (c *Cli) UnlockWallet(wallet string) error {
return err return err
} }
func (c *Cli) UpdateEntry(entry Entry) error { func (c *Cli) UpdateEntry(entry Entry) bool {
entry.Name = c.InputBox("Name", entry.Name, false) entry.Name = c.InputBox("Name", entry.Name, false)
entry.Group = c.InputBox("Group", entry.Group, false) entry.Group = c.InputBox("Group", entry.Group, false)
entry.URI = c.InputBox("URI", entry.URI, false) entry.URI = c.InputBox("URI", entry.URI, false)
@ -153,18 +153,20 @@ func (c *Cli) UpdateEntry(entry Entry) error {
err := c.Wallet.UpdateEntry(entry) err := c.Wallet.UpdateEntry(entry)
if err != nil { if err != nil {
return err c.NotificationBox(fmt.Sprintf("%s", err), true)
return false
} }
err = c.Wallet.Save() err = c.Wallet.Save()
if err != nil { if err != nil {
return err c.NotificationBox(fmt.Sprintf("%s", err), true)
return false
} }
return nil return true
} }
func (c *Cli) AddEntry() error { func (c *Cli) AddEntry() bool {
entry := Entry{} entry := Entry{}
entry.GenerateID() entry.GenerateID()
entry.Name = c.InputBox("Name", "", false) entry.Name = c.InputBox("Name", "", false)
@ -177,15 +179,17 @@ func (c *Cli) AddEntry() error {
err := c.Wallet.AddEntry(entry) err := c.Wallet.AddEntry(entry)
if err != nil { if err != nil {
return err c.NotificationBox(fmt.Sprintf("%s", err), true)
return false
} }
err = c.Wallet.Save() err = c.Wallet.Save()
if err != nil { if err != nil {
return err c.NotificationBox(fmt.Sprintf("%s", err), true)
return false
} }
return nil return true
} }
func (c *Cli) ListEntries() { func (c *Cli) ListEntries() {
@ -229,22 +233,13 @@ func (c *Cli) ListEntries() {
index = l.SelectedRow index = l.SelectedRow
case "<Escape>": case "<Escape>":
pattern = "" pattern = ""
group = ""
refresh = true refresh = true
case "n": case "n":
err := c.AddEntry() refresh = c.AddEntry()
if err == nil {
refresh = true
} else {
c.NotificationBox(fmt.Sprintf("%s", err), true)
}
case "u": case "u":
if len(entries) > 0 && index >= 0 && index < len(entries) { if len(entries) > 0 && index >= 0 && index < len(entries) {
err := c.UpdateEntry(entries[index]) refresh = c.UpdateEntry(entries[index])
if err == nil {
refresh = true
} else {
c.NotificationBox(fmt.Sprintf("%s", err), true)
}
} }
case "/": case "/":
pattern = c.InputBox("Search", pattern, false) pattern = c.InputBox("Search", pattern, false)