Skip to content

Commit

Permalink
Immediately after changing currency refresh the current coins cointop…
Browse files Browse the repository at this point in the history
  • Loading branch information
lyricnz committed Oct 25, 2021
1 parent b921c09 commit 24a2d8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cointop/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (ct *Cointop) SetCurrencyConverstionFn(convert string) func() error {
if err := ct.Save(); err != nil {
return err
}

go ct.UpdateCurrentPageCoins()
go ct.RefreshAll()
return nil
}
Expand Down
16 changes: 16 additions & 0 deletions cointop/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ func (ct *Cointop) UpdateCoins() error {
return nil
}

// UpdateCoins updates all the coins in the current page
func (ct *Cointop) UpdateCurrentPageCoins() error {
log.Debugf("UpdateCurrentPageCoins(%d)", len(ct.State.coins))
currentPageCoins := make([]string, len(ct.State.coins))
for i, entry := range ct.State.coins {
currentPageCoins[i] = entry.Name
}

coins, err := ct.api.GetCoinDataBatch(currentPageCoins, ct.State.currencyConversion)
if err != nil {
return err
}
go ct.processCoins(coins)
return nil
}

// ProcessCoinsMap processes coins map
func (ct *Cointop) processCoinsMap(coinsMap map[string]types.Coin) {
log.Debug("ProcessCoinsMap()")
Expand Down

0 comments on commit 24a2d8f

Please sign in to comment.