Skip to content

Commit

Permalink
fix sync callback balance = 0 case
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Nov 19, 2019
1 parent cbf6f2e commit f27d5a7
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions ui/screens.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def __init__(self, app):

# Update the home screen when the balance signal is received.
app.registerSignal(ui.BALANCE_SIGNAL, self.balanceUpdated)
app.registerSignal(ui.SYNC_SIGNAL, self.setTicketStats)
app.registerSignal(ui.SYNC_SIGNAL, self.walletSynced)

layout = self.layout
layout.setAlignment(Q.ALIGN_LEFT)
Expand Down Expand Up @@ -515,18 +515,24 @@ def balanceUpdated(self, bal):
self.balance = bal
if self.ticketStats:
self.setTicketStats()
def walletSynced(self):
"""
Connected to the ui.SYNC_SIGNAL. Remove loading spinner and set ticket
stats.
"""
acct = self.app.wallet.selectedAccount
self.ticketStats = acct.ticketStats()
self.setTicketStats()
self.spinner.setVisible(False)
self.stakeBttn.setVisible(True)
def setTicketStats(self):
"""
Set the staking statistics.
"""
acct = self.app.wallet.selectedAccount
balance = self.balance
stats = acct.ticketStats()
if stats and balance and balance.total > 0:
self.spinner.setVisible(False)
self.stakeBttn.setVisible(True)
self.statsLbl.setText("%s%% staked" % helpers.formatNumber(stats.value/balance.total*100))
self.ticketStats = stats
staked = 0
if self.ticketStats and self.balance.total > 0:
staked = self.ticketStats.value/self.balance.total
self.statsLbl.setText("%s%% staked" % helpers.formatNumber(staked*100))
def spendClicked(self, e=None):
"""
Display a form to send funds to an address. A Qt Slot, but any event
Expand Down

0 comments on commit f27d5a7

Please sign in to comment.