-
Notifications
You must be signed in to change notification settings - Fork 189
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] Add exit dialog when entering passphrase #563
Changes from 1 commit
59bcfda
1670bf6
530e334
d8b7672
d7efbb3
6c550e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,19 +323,51 @@ def __init__(self): | |
|
||
|
||
def run(self): | ||
ret = self.run_screen(seed_screens.SeedAddPassphraseScreen, passphrase=self.seed.passphrase) | ||
ret_passphrase, ret_btn = self.run_screen(seed_screens.SeedAddPassphraseScreen, passphrase=self.seed.passphrase) | ||
|
||
if ret == RET_CODE__BACK_BUTTON: | ||
return Destination(BackStackView) | ||
|
||
# The new passphrase will be the return value; it might be empty. | ||
self.seed.set_passphrase(ret) | ||
if len(self.seed.passphrase) > 0: | ||
self.seed.set_passphrase(ret_passphrase) | ||
if ret_btn == RET_CODE__BACK_BUTTON: | ||
alvroble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if len(self.seed.passphrase) > 0: | ||
return Destination(SeedAddPassphraseExitDialogView) | ||
else: | ||
return Destination(BackStackView) | ||
elif len(self.seed.passphrase) > 0: | ||
alvroble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return Destination(SeedReviewPassphraseView) | ||
else: | ||
return Destination(SeedFinalizeView) | ||
|
||
|
||
class SeedAddPassphraseExitDialogView(View): | ||
EXIT = ("Exit", None, None, "red") | ||
CONTINUE = "Continue editing" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.seed = self.controller.storage.get_pending_seed() | ||
|
||
|
||
def run(self): | ||
passphrase = self.seed.passphrase | ||
|
||
button_data = [self.EXIT, self.CONTINUE] | ||
|
||
selected_menu_num = self.run_screen( | ||
WarningScreen, | ||
title="Exit", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: "Abandon Passphrase?" but only if it would fit. else perhaps: title "Abandon Edting" with text = "Exiting will abandon the BIP-39 Passphrase" It's just a suggestion. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @jdlcdl. I agree with this suggestion for both title and text, and leaving button texts as proposed. Let's see if other contributors comment on this, if not then I'll push the changes you proposed (after checking that new title fits). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since still waiting for feedback from others, please feel free to adjust to the best pr that you can (text changes and button preferences as you like) w/ another commit and push. I like the text just above, and the thought of a deliberate exit by "down" and "press" to avoid accidentally abandoning the long passphrase. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the psychology of the user what happens we the don't know what is BIP-39? Do we really need to add BIP-39. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your comment, @dulcedu. I believe the use of BIP numbers throughout the UX is something that should be considered globally. In this particular case, I think it's good practice to keep "BIP-39 Passphrase" to maintain consistency with the overall UX design. I think this point could unleash a broader debate to balance between design accessibility to a wide audience and adhering to best practices. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I appreciate the thoughts on BIP-39, and its 100% fair perspective on it being a technical detail. There are unfortunately several kinds of passwords/phrases that can be implemented with wallets / private keys, so I think it makes sense to include it for clarity somewhere in the UI. |
||
status_headline=None, | ||
text=f"Please confirm that you want to exit", | ||
show_back_button=False, | ||
button_data=button_data, | ||
) | ||
|
||
if button_data[selected_menu_num] == self.EXIT: | ||
self.seed.set_passphrase("") | ||
return Destination(SeedFinalizeView) | ||
|
||
elif button_data[selected_menu_num] == self.CONTINUE: | ||
return Destination(SeedAddPassphraseView) | ||
|
||
|
||
class SeedReviewPassphraseView(View): | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty uncomfortable with this change to return a tuple and especially the downstream changes it creates in the related flow-based tests.
We have type hints for what we expect
View.run_screen
to return:https://github.com/SeedSigner/seedsigner/blob/dev/src/seedsigner/views/view.py#L104
Since this is python, obviously we're not restricted to just those two types.
It's not terrible to break the existing convention in this way, but I still strongly dislike it. Though admittedly it's probably more on aesthetic / esoteric grounds; I doubt this would cause problems for us in the future. That being said, the flow-based tests are only possible because we held extreme discipline throughout the code in plenty of other areas.
(and we have a matching type hint for
FlowStep
that's no longer completely accurate: https://github.com/SeedSigner/seedsigner/blob/dev/tests/base.py#L109)But I can't think of an alternate solution, either. Well, not a good one, at least.
Very minor improvement: return a
dict
instead of a tuple?And then the View would ask:
There's barely a difference using a dict vs tuples, but when in doubt I prefer the self-documenting nature of having dict keys.
Ultimately
Screen
probably should have returned something like aResponse
object that could handle a more complex use case like this. But that would be a huge refactor. But returning adict
here feels like a half-step in that direction and so is another very small nod in favor of dict over tuple.AT THE VERY LEAST this Screen should include a
TODO
comment noting its unusual return value approach.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @kdmukai. I just pushed d8b7672 following your suggestion for a dict approach and a TODO comment noting the unusual return value.
Maybe it's okay with that, or maybe we should include another comment regarding the type hints in the files you mentioned.