fix(@desktop/onboarding): not remove seed phrases when changing number of words

Fix #5613
This commit is contained in:
Michal Iskierko 2022-05-23 13:08:00 +02:00 committed by Iuri Matias
parent 1ef13df326
commit b2d75995e4
1 changed files with 9 additions and 11 deletions

View File

@ -20,7 +20,6 @@ OnboardingBasePage {
property bool existingUser: (root.state === "existingUser") property bool existingUser: (root.state === "existingUser")
property var mnemonicInput: [] property var mnemonicInput: []
property string mnemonicString
signal seedValidated() signal seedValidated()
@ -121,9 +120,10 @@ OnboardingBasePage {
} }
} }
onCurrentIndexChanged: { onCurrentIndexChanged: {
root.mnemonicString = ""; root.mnemonicInput = root.mnemonicInput.filter(function(value) {
root.mnemonicInput = []; return value.pos <= root.tabs[switchTabBar.currentIndex]
submitButton.enabled = false; })
submitButton.checkMnemonicLength()
} }
} }
clip: true clip: true
@ -292,20 +292,19 @@ OnboardingBasePage {
anchors.topMargin: 24 anchors.topMargin: 24
enabled: false enabled: false
function checkMnemonicLength() { function checkMnemonicLength() {
submitButton.enabled = (root.mnemonicInput.length >= grid.count); submitButton.enabled = (root.mnemonicInput.length === root.tabs[switchTabBar.currentIndex])
} }
text: root.existingUser ? qsTr("Restore Status Profile") : qsTr("Import") text: root.existingUser ? qsTr("Restore Status Profile") : qsTr("Import")
onClicked: { onClicked: {
root.mnemonicString = ""; let mnemonicString = "";
var sortTable = mnemonicInput.sort(function (a, b) { var sortTable = mnemonicInput.sort(function (a, b) {
return a.pos - b.pos; return a.pos - b.pos;
}); });
for (var i = 0; i < mnemonicInput.length; i++) { for (var i = 0; i < mnemonicInput.length; i++) {
root.mnemonicString += sortTable[i].seed + ((i === (grid.count-1)) ? "" : " "); mnemonicString += sortTable[i].seed + ((i === (grid.count-1)) ? "" : " ");
} }
if (Utils.isMnemonic(root.mnemonicString) && !OnboardingStore.validateMnemonic(root.mnemonicString)) { if (Utils.isMnemonic(mnemonicString) && !OnboardingStore.validateMnemonic(mnemonicString)) {
OnboardingStore.importMnemonic(root.mnemonicString) OnboardingStore.importMnemonic(mnemonicString)
root.mnemonicString = "";
root.mnemonicInput = []; root.mnemonicInput = [];
} else { } else {
invalidSeedTxt.visible = true; invalidSeedTxt.visible = true;
@ -316,7 +315,6 @@ OnboardingBasePage {
} }
onBackClicked: { onBackClicked: {
root.mnemonicString = "";
root.mnemonicInput = []; root.mnemonicInput = [];
root.exit(); root.exit();
} }