fix(core): streamline progress animation disabling

pull/2251/head
matejcik 2 years ago committed by Martin Milata
parent ee694f36cf
commit e47bcee4a4

@ -23,12 +23,12 @@ async def get_firmware(ctx: Context, _msg: GetFirmware) -> Success:
action="Do you want to extract device firmware?",
description="Your seed will not be revealed.",
)
if not utils.DISABLE_ANIMATION:
workflow.close_others()
draw_simple_text("Please wait")
sector_buffer = bytearray(CHUNK_SIZE)
packet = FirmwareChunk(chunk=sector_buffer)
workflow.close_others()
draw_simple_text("Please wait")
progress = 0
_render_progress(progress, PROGRESS_TOTAL)
for i in range(utils.FIRMWARE_SECTORS_COUNT):

@ -10,14 +10,11 @@ if TYPE_CHECKING:
async def get_firmware_hash(ctx: Context, msg: GetFirmwareHash) -> FirmwareHash:
render_func = None
if not DISABLE_ANIMATION:
workflow.close_others()
draw_simple_text("Please wait")
render_func = _render_progress
workflow.close_others()
draw_simple_text("Please wait")
try:
hash = firmware_hash(msg.challenge, render_func)
hash = firmware_hash(msg.challenge, _render_progress)
except ValueError as e:
raise wire.DataError(str(e))
@ -25,6 +22,7 @@ async def get_firmware_hash(ctx: Context, msg: GetFirmwareHash) -> FirmwareHash:
def _render_progress(progress: int, total: int) -> None:
p = 1000 * progress // total
ui.display.loader(p, False, 18, ui.WHITE, ui.BG)
ui.refresh()
if not DISABLE_ANIMATION:
p = 1000 * progress // total
ui.display.loader(p, False, 18, ui.WHITE, ui.BG)
ui.refresh()

Loading…
Cancel
Save