-
Notifications
You must be signed in to change notification settings - Fork 306
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
fix: back up same name #10449
fix: back up same name #10449
Conversation
This reverts commit f0d1662.
@@ -20,7 +20,17 @@ export async function internal_wallet_restore(backup: NormalizedBackup.WalletBac | |||
for (const wallet of backup) { | |||
try { | |||
const wallets = await getWallets() | |||
const name = wallet.name || generateNewWalletName(wallets) | |||
let nameExistsIndex = 0 |
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.
A less scary solution(w/o while):
parse the index of every wallet name. Compute the max index among them and the next qualified index is the max index + 1.
while (nameExists) { | ||
nameExistsIndex += 1 | ||
// eslint-disable-next-line @typescript-eslint/no-loop-func | ||
nameExists = wallets.some((x) => x.name === `${wallet.name} (${nameExistsIndex})`) |
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.
This will create names like: Address (1)(1)(1)
.
Description
https://mask.atlassian.net/browse/MF-4653
https://mask.atlassian.net/browse/MF-4931
Closes # (NO_ISSUE)
Type of change
Previews
Checklist
console.log
sIf this PR depends on external APIs:
chrome-extension://[id]
moz-extension://[id]