feat: loading spinner while resolving ens name

This commit is contained in:
hydrogen 2020-11-13 17:28:27 +02:00 committed by Pascal Precht
parent 0f6d40f931
commit df9ac80eb9
1 changed files with 19 additions and 16 deletions

View File

@ -3,6 +3,7 @@ import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13 import QtQuick.Layouts 1.13
import "../../../../imports" import "../../../../imports"
import "../../../../shared" import "../../../../shared"
import "../../../../shared/status"
import "./" import "./"
ModalPopup { ModalPopup {
@ -11,6 +12,8 @@ ModalPopup {
property string pubKey : ""; property string pubKey : "";
property string ensUsername : ""; property string ensUsername : "";
property bool loading: false;
function validate() { function validate() {
if (!Utils.isChatKey(chatKey.text) && !Utils.isValidETHNamePrefix(chatKey.text)) { if (!Utils.isChatKey(chatKey.text) && !Utils.isValidETHNamePrefix(chatKey.text)) {
validationError = "This needs to be a valid chat key or ENS username"; validationError = "This needs to be a valid chat key or ENS username";
@ -25,6 +28,7 @@ ModalPopup {
property var resolveENS: Backpressure.debounce(popup, 500, function (ensName){ property var resolveENS: Backpressure.debounce(popup, 500, function (ensName){
chatsModel.resolveENS(ensName) chatsModel.resolveENS(ensName)
loading = true
}); });
function onKeyReleased(){ function onKeyReleased(){
@ -86,6 +90,7 @@ ModalPopup {
ensUsername.text = chatsModel.formatENSUsername(chatKey.text) + " • " + Utils.compactAddress(resolvedPubKey, 4) ensUsername.text = chatsModel.formatENSUsername(chatKey.text) + " • " + Utils.compactAddress(resolvedPubKey, 4)
pubKey = resolvedPubKey; pubKey = resolvedPubKey;
} }
loading = false;
} }
} }
} }
@ -166,24 +171,22 @@ ModalPopup {
} }
} }
footer: Button { footer: Item {
width: 44
height: 44
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.top: parent.top
anchors.right: parent.right anchors.right: parent.right
SVGImage { anchors.left: parent.left
source: pubKey === "" ? "../../../img/arrow-button-inactive.svg" : "../../../img/arrow-btn-active.svg"
width: 50 StatusButton {
height: 50 anchors.right: parent.right
} anchors.bottom: parent.bottom
background: Rectangle { anchors.topMargin: Style.current.halfPadding
color: "transparent" id: submitBtn
} state: loading ? "pending" : "default"
MouseArea { text: qsTr("Start chat")
id: btnMAnewChat enabled: pubKey !== ""
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked : doJoin() onClicked : doJoin()
} }
} }
} }