Skip to content

Commit

Permalink
cta_back(): 2nd item returned is 1st param, NOT a callable returning …
Browse files Browse the repository at this point in the history
…1st param
  • Loading branch information
Jean Do committed Jul 18, 2024
1 parent 62f6022 commit 190a388
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/krux/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def load_method(self):
t("Load from SD card"),
None if not self.has_sd_card() else lambda: None,
),
cta_back(None),
cta_back(lambda: None),
],
)
index, _ = load_menu.run_loop()
Expand Down Expand Up @@ -904,14 +904,14 @@ def choose_len_mnemonic(ctx):
[
(t("12 words"), lambda: 12),
(t("24 words"), lambda: 24),
cta_back(None),
cta_back(lambda: None),
],
)
_, num_words = submenu.run_loop()
ctx.display.clear()
return num_words


def cta_back(status=MENU_EXIT, label=t("Back")):
def cta_back(status=lambda: MENU_EXIT, label=t("Back")):
"""Reusable 'call-to-action: go back'. Currently a menu item tuple"""
return ("< " + label, lambda: status)
return ("< " + label, status)
2 changes: 1 addition & 1 deletion src/krux/pages/home_pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _sign_menu(self):
t("Sign to SD card"),
None if not self.has_sd_card() else lambda: None,
),
cta_back(None),
cta_back(lambda: None),
],
)
index, _ = sign_menu.run_loop()
Expand Down
2 changes: 1 addition & 1 deletion src/krux/pages/home_pages/sign_message_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def sign_message(self):
t("Sign to SD card"),
None if not self.has_sd_card() else lambda: None,
),
cta_back(None),
cta_back(lambda: None),
],
)
index, _ = sign_menu.run_loop()
Expand Down
4 changes: 1 addition & 3 deletions src/krux/pages/settings_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ def handler():
# Case for "Back" on the main Settings
if settings_namespace.namespace == Settings.namespace:
items.append((t("Factory Settings"), self.restore_settings))
# TODO: solve below so tests don't fail "assert_has_calls" checks
# items.append(cta_back(self._settings_exit_check))
items.append(("< " + t("Back"), self._settings_exit_check))
items.append(cta_back(self._settings_exit_check))
else:
items.append(cta_back())

Expand Down

0 comments on commit 190a388

Please sign in to comment.