Skip to content

Commit

Permalink
SFT-1943: fixed predictive text page holding onto previous entries
Browse files Browse the repository at this point in the history
  • Loading branch information
mjg-foundation committed Jul 24, 2024
1 parent f1e076e commit fbfd59e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ async def enter_backup_password(self):
result = await PredictiveTextInputPage(
word_list='bytewords',
total_words=NUM_BACKUP_PASSWORD_WORDS,
initial_words=self.backup_password_words).show()
initial_words=self.backup_password_words,
initial_prefixes=self.backup_password_prefixes).show()

(backup_password_words, self.backup_password_prefixes, _) = result
if result is None:
cancel = await QuestionPage(text='Cancel password entry? ' +
'All progress will be lost.').show()
if cancel:
self.back()
else:
self.backup_password_words, self.backup_password_prefixes = result
self.backup_password_words = backup_password_words
self.decryption_password = (' ').join(self.backup_password_words)
# print('6 words: decryption_password={}'.format(self.decryption_password))
self.goto(self.do_restore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def __init__(self, refresh_cards_when_done=False, autobackup=True, full_backup=F
self.validate_text = None
self.index = 0
self.seed_words = []
self.prefixes = []
self.full_backup = full_backup
self.autobackup = autobackup
self.statusbar = {'title': 'IMPORT SEED', 'icon': 'ICON_SEED'}
Expand Down Expand Up @@ -103,9 +104,12 @@ async def enter_seed_words(self):
word_list='bip39',
total_words=self.seed_length,
initial_words=self.seed_words,
initial_prefixes=self.prefixes,
start_index=self.index).show()

if result is None:
seed_words, self.prefixes, get_last_word = result

if seed_words is None:
cancel = await QuestionPage(
text='Cancel seed entry? All progress will be lost.').show()

Expand All @@ -116,8 +120,7 @@ async def enter_seed_words(self):
self.index = 0
return

self.seed_words, self.prefixes, get_last_word = result

self.seed_words = seed_words
if get_last_word:

last_word = await RandomFinalWordFlow(self.seed_words).run()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def __init__(self,
total_words=24,
card_header=None,
statusbar=None,
initial_words=[],
initial_prefixes=[],
initial_words=None,
initial_prefixes=None,
left_micron=microns.Back,
right_micron=microns.Forward,
start_index=None):
Expand All @@ -45,8 +45,8 @@ def __init__(self,
self.total_words = total_words
self.word_idx = start_index if (start_index is not None and start_index < self.total_words) else 0
self.prediction_idx = 0
self.selected_words = initial_words
self.prefixes = initial_prefixes
self.selected_words = initial_words or []
self.prefixes = initial_prefixes or []
self.predictions = []

with Stylize(self) as default:
Expand Down Expand Up @@ -97,7 +97,6 @@ def update_predictions(self):
# print('Lookup words for {}'.format(prefix))
set_list(self.prefixes, self.word_idx, prefix)
self.predictions = get_words_matching_prefix(prefix, max=10, word_list=self.word_list)
print("len(predictions): {}".format(len(self.predictions)))
elif self.word_idx == self.total_words - 1:
self.predictions = [RANDOM_WORD_STRING]
else:
Expand Down Expand Up @@ -208,7 +207,7 @@ def left_action(self, is_pressed):
self.update_title()
self.update_predictions()
else:
self.set_result(None)
self.set_result((None, self.prefixes, False))

def attach(self, group):
super().attach(group)
Expand Down

0 comments on commit fbfd59e

Please sign in to comment.