fix(Wallet): fix import seed in account creation
Remove the workaround, to the approach of using the complete last word event, for three letters seed-words. The three letters condition introduced another side effect when completing the "sentence" and made the _internal.mnemonicInput contain an extra duplicate word. Unify the event `doneInsertingWord` generation for the internal purpose with the external. This will trigger a secondary for some usage but I see no problem with even in other usages. Fix corner case when user enters a correct seed word that is not singular and uses the mouse to jump. In that case the doneInsertingWord is not triggered Fixes: #7715
This commit is contained in:
parent
8a45e34870
commit
057d0c565e
|
@ -98,8 +98,12 @@ Item {
|
|||
*/
|
||||
signal editClicked()
|
||||
|
||||
function setWord(word) {
|
||||
seedWordInput.input.edit.text = word
|
||||
function setWord(seedWord) {
|
||||
let seedWordTrimmed = seedWord.trim()
|
||||
seedWordInput.input.edit.text = seedWordTrimmed
|
||||
seedWordInput.input.edit.cursorPosition = seedWordInput.text.length
|
||||
seedSuggestionsList.model = 0
|
||||
root.doneInsertingWord(seedWordTrimmed)
|
||||
}
|
||||
|
||||
onActiveFocusChanged: {
|
||||
|
@ -108,6 +112,12 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
property bool isInputValidWord: false
|
||||
}
|
||||
|
||||
StatusInput {
|
||||
id: seedWordInput
|
||||
|
||||
|
@ -121,12 +131,15 @@ Item {
|
|||
}
|
||||
input.acceptReturn: true
|
||||
onTextChanged: {
|
||||
d.isInputValidWord = false
|
||||
filteredList.clear();
|
||||
let textToCheck = text.trim()
|
||||
if (textToCheck !== "") {
|
||||
for (var i = 0; i < inputList.count; i++) {
|
||||
if (inputList.get(i).seedWord.startsWith(textToCheck)) {
|
||||
filteredList.insert(filteredList.count, {"seedWord": inputList.get(i).seedWord});
|
||||
if(inputList.get(i).seedWord === textToCheck)
|
||||
d.isInputValidWord = true
|
||||
}
|
||||
}
|
||||
seedSuggestionsList.model = filteredList;
|
||||
|
@ -144,7 +157,7 @@ Item {
|
|||
onKeyPressed: {
|
||||
if (input.edit.keyEvent === Qt.Key_Tab || input.edit.keyEvent === Qt.Key_Return || input.edit.keyEvent === Qt.Key_Enter) {
|
||||
if (!!text && seedSuggestionsList.count > 0) {
|
||||
seedSuggestionsList.completeWordFill(filteredList.get(seedSuggestionsList.currentIndex).seedWord)
|
||||
root.setWord(filteredList.get(seedSuggestionsList.currentIndex).seedWord)
|
||||
event.accepted = true
|
||||
return
|
||||
}
|
||||
|
@ -160,6 +173,17 @@ Item {
|
|||
onEditClicked: {
|
||||
root.editClicked();
|
||||
}
|
||||
// Consider word inserted if input looses focus while a valid word is present ("user" clicks outside)
|
||||
Connections {
|
||||
target: seedWordInput.input.edit
|
||||
onActiveFocusChanged: {
|
||||
if (!seedWordInput.input.edit.activeFocus && d.isInputValidWord) {
|
||||
// There are so many side effects regarding focus and doneInsertingWord that we need to reset this flag not to be processed again.
|
||||
d.isInputValidWord = false
|
||||
root.doneInsertingWord(root.text.trim())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
|
@ -201,14 +225,6 @@ Item {
|
|||
seedSuggestionsList.currentIndex = 0
|
||||
}
|
||||
|
||||
function completeWordFill(seedWord) {
|
||||
let seedWordTrimmed = seedWord.trim();
|
||||
root.setWord(seedWordTrimmed);
|
||||
seedWordInput.input.edit.cursorPosition = seedWordInput.text.length;
|
||||
seedSuggestionsList.model = 0;
|
||||
root.doneInsertingWord(seedWordTrimmed);
|
||||
}
|
||||
|
||||
clip: true
|
||||
ScrollBar.vertical: ScrollBar { }
|
||||
delegate: Item {
|
||||
|
@ -238,7 +254,7 @@ Item {
|
|||
cursorShape: Qt.PointingHandCursor
|
||||
hoverEnabled: true
|
||||
onClicked: {
|
||||
seedSuggestionsList.completeWordFill(seedWord)
|
||||
root.setWord(seedWord)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ StatusGridView {
|
|||
grid.itemAtIndex(i).textEdit.reset()
|
||||
}
|
||||
}
|
||||
grid.isValid = false
|
||||
}
|
||||
|
||||
function validate() {
|
||||
|
@ -118,14 +119,9 @@ StatusGridView {
|
|||
timer.setTimeout(function(){
|
||||
_internal.mnemonicInput = []
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
try {
|
||||
grid.itemAtIndex(i).setWord(words[i])
|
||||
if (words[i].length === 3) {
|
||||
grid.addWord(i + 1, words[i])
|
||||
}
|
||||
} catch (e) {
|
||||
// Getting items outside of the current view might not work
|
||||
}
|
||||
const item = grid.itemAtIndex(i)
|
||||
if (item && item.leftComponentText)
|
||||
item.setWord(words[i])
|
||||
}
|
||||
}, timeout);
|
||||
|
||||
|
@ -220,7 +216,7 @@ StatusGridView {
|
|||
var wordIndex = _internal.mnemonicInput.findIndex(x => x.pos === leftComponentText);
|
||||
if (wordIndex > -1) {
|
||||
_internal.mnemonicInput.splice(wordIndex , 1);
|
||||
grid.isValid = _internal.mnemonicInput.length === grid.model
|
||||
grid.isValid = _internal.mnemonicInput.length === grid.model
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue