Skip to content
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

SFT-2757: renaming accounts broken #389

Merged
merged 2 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ async def confirm_delete(self):
self.set_result(False)

async def do_delete(self):
from common import settings

(error,) = await spinner_task('Deleting Account', delete_account_task,
args=[self.account.get('acct_num')])
args=[self.account.get('acct_num'),
settings.get('xfp')])
if error is None:
import common
from utils import start_task
Expand Down
11 changes: 8 additions & 3 deletions ports/stm32/boards/Passport/modules/flows/rename_account_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def __init__(self):
super().__init__(initial_state=initial_state, name='RenameAccountFLow')

async def ask_for_name(self):
from common import settings

name = self.account.get('name') if self.new_account_name is None else self.new_account_name
result = await TextInputPage(initial_text=name,
max_length=MAX_ACCOUNT_NAME_LEN,
Expand All @@ -38,7 +40,7 @@ async def ask_for_name(self):
self.new_account_name = result

# Check for existing account with this name
existing_account = get_account_by_name(self.new_account_name)
existing_account = get_account_by_name(self.new_account_name, settings.get('xfp'))
if existing_account is not None:
await ErrorPage(text='Account #{} already exists with the name "{}".'.format(
existing_account.get('acct_num'), self.new_account_name)).show()
Expand All @@ -49,9 +51,12 @@ async def ask_for_name(self):
self.set_result(False)

async def do_rename(self):
from common import ui
from common import ui, settings

(error,) = await spinner_task('Renaming account', rename_account_task,
args=[self.account.get('acct_num'), self.new_account_name])
args=[self.account.get('acct_num'),
self.new_account_name,
settings.get('xfp')])
if error is None:
import common
from utils import start_task
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from utils import get_accounts


async def delete_account_task(on_done, account_num):
async def delete_account_task(on_done, account_num, xfp):
from common import settings

accounts = get_accounts()
accounts = list(filter(lambda acct: acct.get('acct_num') != account_num, accounts))
accounts = list(filter(lambda acct: (acct.get('acct_num') != account_num or acct.get('xfp') != xfp), accounts))
settings.set('accounts', accounts)
settings.save()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from utils import get_accounts


async def rename_account_task(on_done, account_num, account_name):
async def rename_account_task(on_done, account_num, account_name, xfp):
from common import settings

accounts = get_accounts()
for account in accounts:
if account.get('acct_num') == account_num:
if account.get('acct_num') == account_num and account.get('xfp') == xfp:
account['name'] = account_name
break

Expand Down
Loading