Fix issues of sort by view

pull/281/head
Vuong 2 years ago
parent 08c7a026cc
commit 06c56b599a
No known key found for this signature in database
GPG Key ID: F4C603CC37B47A46

@ -289,11 +289,11 @@ func NewCointop(config *Config) (*Cointop, error) {
selectedChartRange: DefaultChartRange,
shortcutKeys: DefaultShortcuts(),
selectedView: CoinsView,
page: 0,
perPage: int(perPage),
viewSorts: map[string]*sortConstraint{
CoinsView: {DefaultSortBy, false},
},
page: 0,
perPage: int(perPage),
portfolio: &Portfolio{
Entries: make(map[string]*PortfolioEntry),
},

@ -89,7 +89,7 @@ func (ct *Cointop) Sort(sortCons *sortConstraint, list []*Coin, renderHeaders bo
// SortAsc sorts list of coins in ascending order
func (ct *Cointop) SortAsc() error {
log.Debug("SortAsc()")
ct.State.viewSorts[ct.State.selectedView].sortDesc = true
ct.State.viewSorts[ct.State.selectedView].sortDesc = false
ct.UpdateTable()
return nil
}

@ -269,7 +269,7 @@ func (ct *Cointop) SetSelectedView(viewName string) {
ct.State.lastSelectedView = ct.State.selectedView
ct.State.selectedView = viewName
// init sort constraint for the view in case user travels it in the first time
// init sort constraint for the view if it hasn't been seen before
if _, found := ct.State.viewSorts[viewName]; !found {
ct.State.viewSorts[viewName] = &sortConstraint{DefaultSortBy, false}
}

@ -217,11 +217,11 @@ func (ct *Cointop) UpdateTableHeader() error {
arrow := " "
colorfn := baseColor
if !noSort {
corSortCons := ct.State.viewSorts[ct.State.selectedView]
if corSortCons.sortBy == col {
currentSortCons := ct.State.viewSorts[ct.State.selectedView]
if currentSortCons.sortBy == col {
colorfn = ct.colorscheme.TableHeaderColumnActiveSprintf()
arrow = ArrowUp
if corSortCons.sortDesc {
if currentSortCons.sortDesc {
arrow = ArrowDown
}
}

Loading…
Cancel
Save