fix(ImportCommunityPopup): Support community link (#10557)
This commit is contained in:
parent
88cd44c302
commit
bb6e87deec
|
@ -63,10 +63,7 @@ MembersSelectorBase {
|
||||||
|
|
||||||
function lookupContact(value) {
|
function lookupContact(value) {
|
||||||
|
|
||||||
value = value.trim()
|
value = Utils.dropUserLinkPrefix(value.trim())
|
||||||
|
|
||||||
if (value.startsWith(Constants.userLinkPrefix))
|
|
||||||
value = value.slice(Constants.userLinkPrefix.length)
|
|
||||||
|
|
||||||
if (Utils.isChatKey(value)) {
|
if (Utils.isChatKey(value)) {
|
||||||
processContact(value)
|
processContact(value)
|
||||||
|
|
|
@ -24,8 +24,9 @@ StatusDialog {
|
||||||
property string importErrorMessage
|
property string importErrorMessage
|
||||||
readonly property string inputErrorMessage: isInputValid ? "" : qsTr("Invalid key")
|
readonly property string inputErrorMessage: isInputValid ? "" : qsTr("Invalid key")
|
||||||
readonly property string errorMessage: importErrorMessage || inputErrorMessage
|
readonly property string errorMessage: importErrorMessage || inputErrorMessage
|
||||||
readonly property bool isPrivateKey: Utils.isPrivateKey(keyInput.text)
|
readonly property string inputKey: Utils.dropCommunityLinkPrefix(keyInput.text.trim())
|
||||||
readonly property bool isPublicKey: Utils.isChatKey(keyInput.text)
|
readonly property bool isPrivateKey: Utils.isPrivateKey(inputKey)
|
||||||
|
readonly property bool isPublicKey: Utils.isChatKey(inputKey)
|
||||||
readonly property bool isInputValid: isPrivateKey || isPublicKey
|
readonly property bool isInputValid: isPrivateKey || isPublicKey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,24 +37,24 @@ StatusDialog {
|
||||||
onClicked: root.reject()
|
onClicked: root.reject()
|
||||||
}
|
}
|
||||||
StatusButton {
|
StatusButton {
|
||||||
id: importButton
|
id: importButton
|
||||||
enabled: d.isInputValid
|
enabled: d.isInputValid
|
||||||
text: d.isPrivateKey ? qsTr("Make this an Owner Node") : qsTr("Import")
|
text: d.isPrivateKey ? qsTr("Make this an Owner Node") : qsTr("Import")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
let communityKey = keyInput.text.trim();
|
let communityKey = d.inputKey
|
||||||
if (d.isPrivateKey) {
|
if (d.isPrivateKey) {
|
||||||
if (!communityKey.startsWith("0x")) {
|
if (!communityKey.startsWith("0x")) {
|
||||||
communityKey = "0x" + communityKey;
|
communityKey = "0x" + communityKey;
|
||||||
|
}
|
||||||
|
root.store.importCommunity(communityKey);
|
||||||
|
root.close();
|
||||||
}
|
}
|
||||||
root.store.importCommunity(communityKey);
|
if (d.isPublicKey) {
|
||||||
root.close();
|
importButton.loading = true
|
||||||
}
|
root.store.requestCommunityInfo(communityKey, true)
|
||||||
if (d.isPublicKey) {
|
root.close();
|
||||||
importButton.loading = true
|
}
|
||||||
root.store.requestCommunityInfo(communityKey, true)
|
}
|
||||||
root.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,6 +656,18 @@ QtObject {
|
||||||
return key
|
return key
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dropUserLinkPrefix(text) {
|
||||||
|
if (text.startsWith(Constants.userLinkPrefix))
|
||||||
|
text = text.slice(Constants.userLinkPrefix.length)
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
|
function dropCommunityLinkPrefix(text) {
|
||||||
|
if (text.startsWith(Constants.communityLinkPrefix))
|
||||||
|
text = text.slice(Constants.communityLinkPrefix.length)
|
||||||
|
return text
|
||||||
|
}
|
||||||
|
|
||||||
// Leave this function at the bottom of the file as QT Creator messes up the code color after this
|
// Leave this function at the bottom of the file as QT Creator messes up the code color after this
|
||||||
function isPunct(c) {
|
function isPunct(c) {
|
||||||
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
return /(!|\@|#|\$|%|\^|&|\*|\(|\)|\+|\||-|=|\\|{|}|[|]|"|;|'|<|>|\?|,|\.|\/)/.test(c)
|
||||||
|
|
Loading…
Reference in New Issue