1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-04-21 09:39:02 +00:00
This commit is contained in:
Martin Milata 2025-04-19 14:30:12 +07:00 committed by GitHub
commit 04393e7992
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 4 deletions

View File

@ -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()

View File

@ -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.