Remove fallback to coin.Symbol when loading portfolio. Remove deprecated favoritesBySymbol. (#219)

* Remove fallback to coin.Symbol when loading portfolio (use coin.Name)
* Remove deprecated favoritesBySymbol
pull/220/head
Simon Roberts 3 years ago committed by GitHub
parent 6b6a18d38a
commit da06d5ef14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -48,9 +48,6 @@ type State struct {
defaultChartRange string
maxChartWidth int
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions.
favoritesBySymbol map[string]bool
favorites map[string]bool
favoritesTableColumns []string
favoriteChar string
@ -265,8 +262,6 @@ func NewCointop(config *Config) (*Cointop, error) {
currencyConversion: DefaultCurrency,
defaultChartRange: DefaultChartRange,
maxChartWidth: DefaultMaxChartWidth,
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
favoritesBySymbol: make(map[string]bool),
favorites: make(map[string]bool),
favoritesTableColumns: DefaultCoinTableHeaders,
favoriteChar: DefaultFavoriteChar,
@ -454,21 +449,6 @@ func NewCointop(config *Config) (*Cointop, error) {
ct.State.coins = ct.State.allCoins[0:max]
}
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
// Here we're doing a lookup based on symbol and setting the favorite to the coin name instead of coin symbol.
ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool {
if coin, ok := value.(*Coin); ok {
for k := range ct.State.favoritesBySymbol {
if coin.Symbol == k {
ct.State.favorites[coin.Name] = true
delete(ct.State.favoritesBySymbol, k)
}
}
}
return true
})
var globaldata []float64
chartcachekey := ct.CompositeCacheKey("globaldata", "", "", ct.State.selectedChartRange)
if ct.filecache != nil {

@ -214,10 +214,7 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
return favoritesIfc[i].(string) < favoritesIfc[j].(string)
})
var favoritesBySymbolIfc []interface{}
favoritesMapIfc := map[string]interface{}{
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
"symbols": favoritesBySymbolIfc,
"names": favoritesIfc,
"columns": ct.State.favoritesTableColumns,
"character": ct.State.favoriteChar,
@ -509,13 +506,6 @@ func (ct *Cointop) loadFavoritesFromConfig() error {
continue
}
switch k {
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
case "symbols":
for _, ifc := range ifcs {
if v, ok := ifc.(string); ok {
ct.State.favoritesBySymbol[strings.ToUpper(v)] = true
}
}
case "names":
for _, ifc := range ifcs {
if v, ok := ifc.(string); ok {

@ -491,9 +491,6 @@ func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool) {
var isNew bool
var ok bool
key := strings.ToLower(c.Name)
if p, ok = ct.State.portfolio.Entries[key]; !ok {
// NOTE: if not found then try the symbol
key := strings.ToLower(c.Symbol)
if p, ok = ct.State.portfolio.Entries[key]; !ok {
p = &PortfolioEntry{
Coin: c.Name,
@ -501,7 +498,6 @@ func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool) {
}
isNew = true
}
}
return p, isNew
}

Loading…
Cancel
Save