Reduce number of save calls. #120

pull/122/head
Miguel Mota 3 years ago
parent 36bc8a8790
commit 220a396258
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -194,7 +194,7 @@ func (ct *Cointop) SaveConfig() error {
func (ct *Cointop) parseConfig() error {
ct.debuglog("parseConfig()")
var conf config
path := ct.ConfigFilePath()
path := ct.configFilepath
if _, err := toml.DecodeFile(path, &conf); err != nil {
return err
}

@ -431,7 +431,9 @@ func (ct *Cointop) SetPortfolioHoldings() error {
}
if shouldDelete {
ct.RemovePortfolioEntry(coin.Name)
if err := ct.RemovePortfolioEntry(coin.Name); err != nil {
return err
}
ct.UpdateTable()
if idx > 0 {
idx -= 1
@ -444,10 +446,6 @@ func (ct *Cointop) SetPortfolioHoldings() error {
ct.HighlightRow(idx)
if err := ct.Save(); err != nil {
return err
}
return nil
}
@ -501,9 +499,13 @@ func (ct *Cointop) SetPortfolioEntry(coin string, holdings float64) error {
}
// RemovePortfolioEntry removes a portfolio entry
func (ct *Cointop) RemovePortfolioEntry(coin string) {
func (ct *Cointop) RemovePortfolioEntry(coin string) error {
ct.debuglog("removePortfolioEntry()")
delete(ct.State.portfolio.Entries, strings.ToLower(coin))
if err := ct.Save(); err != nil {
return err
}
return nil
}
// PortfolioEntryExists returns true if portfolio entry exists

@ -218,10 +218,9 @@ func (ct *Cointop) CheckPriceAlert(alert *PriceAlert) error {
}
alert.Expired = true
}
if err := ct.Save(); err != nil {
return err
if err := ct.Save(); err != nil {
return err
}
}
return nil
}

Loading…
Cancel
Save