Skip to content

Commit 83a35df

Browse files
committed
Hide all holding amounts when hidden flag toggled
1 parent 1d29363 commit 83a35df

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

cointop/marketbar.go

+6-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ func (ct *Cointop) UpdateMarketbar() error {
4242
totalstr = humanize.Monetaryf(total, 2)
4343
}
4444

45-
if ct.State.hidePortfolioBalances {
46-
totalstr = HiddenBalanceChars
47-
}
48-
4945
timeframe := ct.State.selectedChartRange
5046
chartname := ct.SelectedCoinName()
5147
var charttitle string
@@ -85,10 +81,15 @@ func (ct *Cointop) UpdateMarketbar() error {
8581
)
8682
}
8783

84+
totalstr = fmt.Sprintf("%s%s", ct.CurrencySymbol(), totalstr)
85+
if ct.State.hidePortfolioBalances {
86+
totalstr = HiddenBalanceChars
87+
}
88+
8889
content = fmt.Sprintf(
8990
"%sTotal Portfolio Value: %s • 24H: %s",
9091
chartInfo,
91-
ct.colorscheme.MarketBarLabelActive(fmt.Sprintf("%s%s", ct.CurrencySymbol(), totalstr)),
92+
ct.colorscheme.MarketBarLabelActive(totalstr),
9293
color24h(fmt.Sprintf("%.2f%%%s", percentChange24H, arrow)),
9394
)
9495
} else {

cointop/portfolio.go

+12
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
145145
})
146146
case "holdings":
147147
text := strconv.FormatFloat(coin.Holdings, 'f', -1, 64)
148+
if ct.State.hidePortfolioBalances {
149+
text = HiddenBalanceChars
150+
}
148151
ct.SetTableColumnWidthFromString(header, text)
149152
ct.SetTableColumnAlignLeft(header, false)
150153
rowCells = append(rowCells,
@@ -272,6 +275,9 @@ func (ct *Cointop) GetPortfolioTable() *table.Table {
272275
percentHoldings = 0
273276
}
274277
text := fmt.Sprintf("%.2f%%", percentHoldings)
278+
if ct.State.hidePortfolioBalances {
279+
text = HiddenBalanceChars
280+
}
275281
ct.SetTableColumnWidthFromString(header, text)
276282
ct.SetTableColumnAlignLeft(header, false)
277283
rowCells = append(rowCells,
@@ -773,6 +779,9 @@ func (ct *Cointop) PrintHoldingsTable(options *TablePrintOptions) error {
773779
} else {
774780
item[i] = strconv.FormatFloat(entry.Holdings, 'f', -1, 64)
775781
}
782+
if hideBalances {
783+
item[i] = HiddenBalanceChars
784+
}
776785
case "balance":
777786
if humanReadable {
778787
item[i] = fmt.Sprintf("%s%s", symbol, humanize.Monetaryf(entry.Balance, 2))
@@ -794,6 +803,9 @@ func (ct *Cointop) PrintHoldingsTable(options *TablePrintOptions) error {
794803
} else {
795804
item[i] = fmt.Sprintf("%.2f", percentHoldings)
796805
}
806+
if hideBalances {
807+
item[i] = HiddenBalanceChars
808+
}
797809
}
798810
}
799811
records[i] = item

docs/content/faq.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ draft: false
185185

186186
## How do I hide my portfolio balances (private mode)?
187187

188-
You can run cointop with the `--hide-portfolio-balances` flag to toggle hide/show portfolio balances or use the keyboard shortcut <kbd>Ctrl</kbd>+<kbd>space</kbd> on the portfolio page.
188+
You can run cointop with the `--hide-portfolio-balances` flag to hide portfolio balances or use the keyboard shortcut <kbd>Ctrl</kbd>+<kbd>space</kbd> on the portfolio page to toggle hide/show.
189189

190190
## I'm getting question marks or weird symbols instead of the correct characters.
191191

0 commit comments

Comments
 (0)