Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit da06d5e

Browse files
authored
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
1 parent 6b6a18d commit da06d5e

3 files changed

Lines changed: 10 additions & 44 deletions

File tree

cointop/cointop.go

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ type State struct {
4848
defaultChartRange string
4949
maxChartWidth int
5050

51-
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions.
52-
favoritesBySymbol map[string]bool
53-
5451
favorites map[string]bool
5552
favoritesTableColumns []string
5653
favoriteChar string
@@ -259,14 +256,12 @@ func NewCointop(config *Config) (*Cointop, error) {
259256
limiter: time.NewTicker(2 * time.Second).C,
260257
filecache: nil,
261258
State: &State{
262-
allCoins: []*Coin{},
263-
cacheDir: DefaultCacheDir,
264-
coinsTableColumns: DefaultCoinTableHeaders,
265-
currencyConversion: DefaultCurrency,
266-
defaultChartRange: DefaultChartRange,
267-
maxChartWidth: DefaultMaxChartWidth,
268-
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
269-
favoritesBySymbol: make(map[string]bool),
259+
allCoins: []*Coin{},
260+
cacheDir: DefaultCacheDir,
261+
coinsTableColumns: DefaultCoinTableHeaders,
262+
currencyConversion: DefaultCurrency,
263+
defaultChartRange: DefaultChartRange,
264+
maxChartWidth: DefaultMaxChartWidth,
270265
favorites: make(map[string]bool),
271266
favoritesTableColumns: DefaultCoinTableHeaders,
272267
favoriteChar: DefaultFavoriteChar,
@@ -454,21 +449,6 @@ func NewCointop(config *Config) (*Cointop, error) {
454449
ct.State.coins = ct.State.allCoins[0:max]
455450
}
456451

457-
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
458-
// Here we're doing a lookup based on symbol and setting the favorite to the coin name instead of coin symbol.
459-
ct.State.allCoinsSlugMap.Range(func(key, value interface{}) bool {
460-
if coin, ok := value.(*Coin); ok {
461-
for k := range ct.State.favoritesBySymbol {
462-
if coin.Symbol == k {
463-
ct.State.favorites[coin.Name] = true
464-
delete(ct.State.favoritesBySymbol, k)
465-
}
466-
}
467-
}
468-
469-
return true
470-
})
471-
472452
var globaldata []float64
473453
chartcachekey := ct.CompositeCacheKey("globaldata", "", "", ct.State.selectedChartRange)
474454
if ct.filecache != nil {

cointop/config.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,7 @@ func (ct *Cointop) ConfigToToml() ([]byte, error) {
214214
return favoritesIfc[i].(string) < favoritesIfc[j].(string)
215215
})
216216

217-
var favoritesBySymbolIfc []interface{}
218217
favoritesMapIfc := map[string]interface{}{
219-
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
220-
"symbols": favoritesBySymbolIfc,
221218
"names": favoritesIfc,
222219
"columns": ct.State.favoritesTableColumns,
223220
"character": ct.State.favoriteChar,
@@ -509,13 +506,6 @@ func (ct *Cointop) loadFavoritesFromConfig() error {
509506
continue
510507
}
511508
switch k {
512-
// DEPRECATED: favorites by 'symbol' is deprecated because of collisions. Kept for backward compatibility.
513-
case "symbols":
514-
for _, ifc := range ifcs {
515-
if v, ok := ifc.(string); ok {
516-
ct.State.favoritesBySymbol[strings.ToUpper(v)] = true
517-
}
518-
}
519509
case "names":
520510
for _, ifc := range ifcs {
521511
if v, ok := ifc.(string); ok {

cointop/portfolio.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -492,15 +492,11 @@ func (ct *Cointop) PortfolioEntry(c *Coin) (*PortfolioEntry, bool) {
492492
var ok bool
493493
key := strings.ToLower(c.Name)
494494
if p, ok = ct.State.portfolio.Entries[key]; !ok {
495-
// NOTE: if not found then try the symbol
496-
key := strings.ToLower(c.Symbol)
497-
if p, ok = ct.State.portfolio.Entries[key]; !ok {
498-
p = &PortfolioEntry{
499-
Coin: c.Name,
500-
Holdings: 0,
501-
}
502-
isNew = true
495+
p = &PortfolioEntry{
496+
Coin: c.Name,
497+
Holdings: 0,
503498
}
499+
isNew = true
504500
}
505501

506502
return p, isNew

0 commit comments

Comments
 (0)