mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 09:21:39 +00:00
trustedcoin: better UX in Qt when cannot connect to TC server
closes #5184
This commit is contained in:
parent
13f3f71125
commit
a62bf2a53a
2 changed files with 22 additions and 11 deletions
|
@ -121,10 +121,20 @@ class Plugin(TrustedCoinPlugin):
|
|||
def prompt_user_for_otp(self, wallet, tx, on_success, on_failure):
|
||||
wallet.handler_2fa.prompt_user_for_otp(wallet, tx, on_success, on_failure)
|
||||
|
||||
def waiting_dialog(self, window, on_finished=None):
|
||||
task = partial(self.request_billing_info, window.wallet)
|
||||
return WaitingDialog(window, 'Getting billing information...', task,
|
||||
on_finished)
|
||||
def waiting_dialog_for_billing_info(self, window, *, on_finished=None):
|
||||
def task():
|
||||
return self.request_billing_info(window.wallet, suppress_connection_error=False)
|
||||
def on_error(exc_info):
|
||||
e = exc_info[1]
|
||||
window.show_error("{header}\n{exc}\n\n{tor}"
|
||||
.format(header=_('Error getting TrustedCoin account info.'),
|
||||
exc=str(e),
|
||||
tor=_('If you keep experiencing network problems, try using a Tor proxy.')))
|
||||
return WaitingDialog(parent=window,
|
||||
message=_('Requesting account info from TrustedCoin server...'),
|
||||
task=task,
|
||||
on_success=on_finished,
|
||||
on_error=on_error)
|
||||
|
||||
@hook
|
||||
def abort_send(self, window):
|
||||
|
@ -134,14 +144,13 @@ class Plugin(TrustedCoinPlugin):
|
|||
if wallet.can_sign_without_server():
|
||||
return
|
||||
if wallet.billing_info is None:
|
||||
self.start_request_thread(wallet)
|
||||
window.show_error(_('Requesting account info from TrustedCoin server...') + '\n' +
|
||||
_('Please try again.'))
|
||||
self.waiting_dialog_for_billing_info(window)
|
||||
return True
|
||||
return False
|
||||
|
||||
def settings_dialog(self, window):
|
||||
self.waiting_dialog(window, partial(self.show_settings_dialog, window))
|
||||
self.waiting_dialog_for_billing_info(window,
|
||||
on_finished=partial(self.show_settings_dialog, window))
|
||||
|
||||
def show_settings_dialog(self, window, success):
|
||||
if not success:
|
||||
|
|
|
@ -465,15 +465,17 @@ class TrustedCoinPlugin(BasePlugin):
|
|||
return f
|
||||
|
||||
@finish_requesting
|
||||
def request_billing_info(self, wallet: 'Wallet_2fa'):
|
||||
def request_billing_info(self, wallet: 'Wallet_2fa', *, suppress_connection_error=True):
|
||||
if wallet.can_sign_without_server():
|
||||
return
|
||||
self.print_error("request billing info")
|
||||
try:
|
||||
billing_info = server.get(wallet.get_user_id()[1])
|
||||
except ErrorConnectingServer as e:
|
||||
self.print_error(str(e))
|
||||
return
|
||||
if suppress_connection_error:
|
||||
self.print_error(str(e))
|
||||
return
|
||||
raise
|
||||
billing_index = billing_info['billing_index']
|
||||
# add segwit billing address; this will be used for actual billing
|
||||
billing_address = make_billing_address(wallet, billing_index, addr_type='segwit')
|
||||
|
|
Loading…
Add table
Reference in a new issue