refactor: add funciton to change the username instead of using a global

This commit is contained in:
Jonathan Rainville 2020-09-28 10:31:00 -04:00 committed by Iuri Matias
parent 6a57eeccb2
commit ba0af727dc
2 changed files with 11 additions and 3 deletions

View File

@ -10,6 +10,8 @@ ModalPopup {
property int nicknameLength: nicknameInput.textField.text.length
readonly property int maxNicknameLength: 32
property bool nicknameTooLong: nicknameLength > maxNicknameLength
property var changeUsername: function () {}
property var changeNickname: function () {}
id: popup
width: 400
@ -91,12 +93,12 @@ ModalPopup {
// Change username title only if it was not an ENS name
if (nicknameInput.textField.text === "") {
// If we removed the nickname, go back to showing the alias
userName = alias
popup.changeUsername(alias)
} else {
userName = nicknameInput.textField.text
popup.changeUsername(nicknameInput.textField.text)
}
}
nickname = nicknameInput.textField.text
popup.changeNickname(nicknameInput.textField.text)
profileModel.changeContactNickname(fromAuthor, nicknameInput.textField.text)
popup.close()
}

View File

@ -305,6 +305,12 @@ ModalPopup {
NicknamePopup {
id: nicknamePopup
changeUsername: function (newUsername) {
popup.userName = newUsername
}
changeNickname: function (newNickname) {
popup.nickname = newNickname
}
}
}