mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-21 09:39:02 +00:00
Merge 3bb3b774c1
into f89e7670c5
This commit is contained in:
commit
04393e7992
@ -10,16 +10,15 @@ if TYPE_CHECKING:
|
||||
async def unpair(msg: BleUnpair) -> None:
|
||||
from trezor.messages import Success
|
||||
from trezor.ui.layouts import confirm_action
|
||||
from trezor.wire.context import get_context
|
||||
from trezor.wire.context import maybe_get_context
|
||||
|
||||
if msg.all:
|
||||
await confirm_action("erase bonds", TR.ble__unpair_title, TR.ble__unpair_all)
|
||||
else:
|
||||
await confirm_action("unpair", TR.ble__unpair_title, TR.ble__unpair_current)
|
||||
|
||||
ctx = get_context()
|
||||
|
||||
await ctx.write(Success(message="Erasing.."))
|
||||
if ctx := maybe_get_context():
|
||||
await ctx.write(Success(message="Erasing..."))
|
||||
|
||||
if msg.all:
|
||||
ble.erase_bonds()
|
||||
|
@ -107,6 +107,13 @@ def get_context() -> Context:
|
||||
return CURRENT_CONTEXT
|
||||
|
||||
|
||||
def maybe_get_context() -> Context | None:
|
||||
"""Variant of the function above, same limitations apply. Needed in special cases
|
||||
where a handler might be invoked over wire or from a homescreen menu (e.g. wipe).
|
||||
"""
|
||||
return CURRENT_CONTEXT
|
||||
|
||||
|
||||
def with_context(ctx: Context, workflow: loop.Task) -> Generator:
|
||||
"""Run a workflow in a particular context.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user