Merge branch 'master' of github.com:cointop-sh/cointop

pull/225/head
Miguel Mota 3 years ago
commit 27ad1a782d
No known key found for this signature in database
GPG Key ID: 67EC1161588A00F9

@ -409,13 +409,18 @@ func (ct *Cointop) GoToPageRowIndex(idx int) error {
// GoToGlobalIndex navigates to the selected row index of all page rows // GoToGlobalIndex navigates to the selected row index of all page rows
func (ct *Cointop) GoToGlobalIndex(idx int) error { func (ct *Cointop) GoToGlobalIndex(idx int) error {
log.Debug("GoToGlobalIndex()") log.Debugf("GoToGlobalIndex(%d)", idx)
target := ct.State.allCoins[idx]
l := ct.TableRowsLen() l := ct.TableRowsLen()
atpage := idx / l atpage := idx / l
ct.SetPage(atpage) ct.SetPage(atpage)
rowIndex := idx % l
ct.HighlightRow(rowIndex)
ct.UpdateTable() ct.UpdateTable()
// Look for the coin in the current page
for i, coin := range ct.State.coins {
if coin == target {
ct.HighlightRow(i)
}
}
return nil return nil
} }

@ -556,25 +556,13 @@ func (ct *Cointop) GetPortfolioSlice() []*Coin {
return sliced return sliced
} }
OUTER: for _, p := range ct.State.portfolio.Entries {
for i := range ct.State.allCoins { coinIfc, _ := ct.State.allCoinsSlugMap.Load(p.Coin)
coin := ct.State.allCoins[i] coin, ok := coinIfc.(*Coin)
p, isNew := ct.PortfolioEntry(coin) if !ok {
if isNew { log.Errorf("Could not find coin %s", p.Coin)
continue continue
} }
// check not already found
updateSlice := -1
for j := range sliced {
if coin.Symbol == sliced[j].Symbol {
if coin.Rank >= sliced[j].Rank {
continue OUTER // skip updates from lower-ranked coins
}
updateSlice = j // update this later
break
}
}
coin.Holdings = p.Holdings coin.Holdings = p.Holdings
balance := coin.Price * p.Holdings balance := coin.Price * p.Holdings
balancestr := fmt.Sprintf("%.2f", balance) balancestr := fmt.Sprintf("%.2f", balance)
@ -583,12 +571,7 @@ OUTER:
} }
balance, _ = strconv.ParseFloat(balancestr, 64) balance, _ = strconv.ParseFloat(balancestr, 64)
coin.Balance = balance coin.Balance = balance
if updateSlice == -1 { sliced = append(sliced, coin)
sliced = append(sliced, coin)
} else {
sliced[updateSlice] = coin
}
} }
sort.Slice(sliced, func(i, j int) bool { sort.Slice(sliced, func(i, j int) bool {

Loading…
Cancel
Save