tw.view: new post_action_cleanup() method
This commit is contained in:
parent
e8ca36af44
commit
b62bebc7b8
3 changed files with 16 additions and 18 deletions
|
|
@ -222,8 +222,7 @@ class MoneroTwView:
|
|||
class action(TwView.action):
|
||||
|
||||
async def a_sync_wallets(self, parent):
|
||||
from ....util import msg, msg_r, ymsg
|
||||
from ....tw.view import CUR_HOME, ERASE_ALL
|
||||
from ....util import msg, ymsg
|
||||
msg('')
|
||||
try:
|
||||
op = xmrwallet_op('sync', parent.cfg, None, None, compat_call=True)
|
||||
|
|
@ -232,11 +231,9 @@ class MoneroTwView:
|
|||
import asyncio
|
||||
ymsg(str(e))
|
||||
await asyncio.sleep(2)
|
||||
msg_r(CUR_HOME + ERASE_ALL)
|
||||
return False
|
||||
raise
|
||||
await op.restart_wallet_daemon()
|
||||
await op.main()
|
||||
await parent.get_data()
|
||||
if parent.scroll:
|
||||
msg_r(CUR_HOME + ERASE_ALL)
|
||||
return 'erase'
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@
|
|||
tw.prune: Tracking wallet pruned listaddresses class for the MMGen suite
|
||||
"""
|
||||
|
||||
from ..util import msg, msg_r, rmsg, ymsg
|
||||
from ..util import msg, rmsg, ymsg
|
||||
from ..color import red, green, gray, yellow
|
||||
from ..obj import ListItemAttr
|
||||
from .addresses import TwAddresses
|
||||
from .view import CUR_HOME, ERASE_ALL
|
||||
|
||||
class TwAddressesPrune(TwAddresses):
|
||||
|
||||
|
|
@ -155,15 +154,12 @@ class TwAddressesPrune(TwAddresses):
|
|||
else:
|
||||
e.tag = True
|
||||
|
||||
if parent.scroll:
|
||||
msg_r(CUR_HOME + ERASE_ALL)
|
||||
return 'erase'
|
||||
|
||||
async def a_unprune(self, parent):
|
||||
for addrnum in self.get_addrnums(parent, 'unprune'):
|
||||
parent.disp_data[addrnum-1].tag = False
|
||||
|
||||
if parent.scroll:
|
||||
msg_r(CUR_HOME + ERASE_ALL)
|
||||
return 'erase'
|
||||
|
||||
async def a_clear_prune_list(self, parent):
|
||||
for d in parent.data:
|
||||
|
|
|
|||
|
|
@ -692,11 +692,19 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
return ur(idx, None)
|
||||
await do_error_msg()
|
||||
|
||||
async def post_action_cleanup(self, ret):
|
||||
if self.scroll and (ret is False or ret in ('redraw', 'erase')):
|
||||
# error messages could leave screen in messy state, so do complete redraw:
|
||||
msg_r(
|
||||
CUR_HOME + ERASE_ALL + (
|
||||
'' if ret == 'erase' else
|
||||
await self.format(display_type='squeezed', interactive=True, scroll=True)))
|
||||
|
||||
class action:
|
||||
|
||||
@enable_echo
|
||||
async def run(self, parent, action_method):
|
||||
return await action_method(parent)
|
||||
await parent.post_action_cleanup(await action_method(parent))
|
||||
|
||||
async def a_print_detail(self, parent):
|
||||
return await self._print(parent, output_type='detail')
|
||||
|
|
@ -763,6 +771,7 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
# None: action aborted by user or no action performed
|
||||
# 'redo': user will be re-prompted for item number
|
||||
# 'redraw': action successfully performed, screen will be redrawn
|
||||
# 'erase': action successfully performed, screen will be erased
|
||||
if usr_ret := await parent.get_idx_from_user(action_method.__name__):
|
||||
ret = await action_method(parent, usr_ret.idx, usr_ret.acct_addr_idx)
|
||||
else:
|
||||
|
|
@ -771,11 +780,7 @@ class TwView(MMGenObject, metaclass=AsyncInit):
|
|||
break
|
||||
await asyncio.sleep(0.5)
|
||||
|
||||
if parent.scroll and (ret is False or ret == 'redraw'):
|
||||
# error messages could leave screen in messy state, so do complete redraw:
|
||||
msg_r(
|
||||
CUR_HOME + ERASE_ALL +
|
||||
await parent.format(display_type='squeezed', interactive=True, scroll=True))
|
||||
await parent.post_action_cleanup(ret)
|
||||
|
||||
async def i_balance_refresh(self, parent, idx, acct_addr_idx=None):
|
||||
if not parent.keypress_confirm(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue