fix(EditCommunityToken): prevent using already existing symbols

Closes #10784
This commit is contained in:
Alexandra Betouni 2023-07-04 16:21:15 +03:00
parent a6494bfe33
commit ce06fc3a99
6 changed files with 22 additions and 4 deletions

View File

@ -35,6 +35,11 @@ SplitView {
allNetworks: enabledNetworks allNetworks: enabledNetworks
accounts: WalletAccountsModel {} accounts: WalletAccountsModel {}
tokensModel: MintedTokensModel {} tokensModel: MintedTokensModel {}
tokensModelWallet: ListModel {
ListElement {
symbol: "MAI"
}
}
onPreviewClicked: logs.logEvent("EditCommunityTokenView::previewClicked") onPreviewClicked: logs.logEvent("EditCommunityTokenView::previewClicked")
} }
} }

View File

@ -57,7 +57,11 @@ SplitView {
enabledNetworks: NetworksModel.enabledNetworks enabledNetworks: NetworksModel.enabledNetworks
allNetworks: enabledNetworks allNetworks: enabledNetworks
accounts: WalletAccountsModel {} accounts: WalletAccountsModel {}
tokensModelWallet: ListModel {
ListElement {
symbol: "MAI"
}
}
onMintCollectible: logs.logEvent("CommunityMintTokensSettingsPanel::mintCollectible") onMintCollectible: logs.logEvent("CommunityMintTokensSettingsPanel::mintCollectible")
onMintAsset: logs.logEvent("CommunityMintTokensSettingsPanel::mintAssets") onMintAsset: logs.logEvent("CommunityMintTokensSettingsPanel::mintAssets")
onDeleteToken: logs.logEvent("CommunityMintTokensSettingsPanel::deleteToken: " + tokenKey) onDeleteToken: logs.logEvent("CommunityMintTokensSettingsPanel::deleteToken: " + tokenKey)

View File

@ -24,6 +24,7 @@ StackView {
// Models: // Models:
property var tokensModel property var tokensModel
property var tokensModelWallet
property var accounts // Expected roles: address, name, color, emoji, walletType property var accounts // Expected roles: address, name, color, emoji, walletType
// Transaction related properties: // Transaction related properties:
@ -183,6 +184,7 @@ StackView {
allNetworks: root.allNetworks allNetworks: root.allNetworks
accounts: root.accounts accounts: root.accounts
tokensModel: root.tokensModel tokensModel: root.tokensModel
tokensModelWallet: root.tokensModelWallet
referenceName: newTokenPage.referenceName referenceName: newTokenPage.referenceName
referenceSymbol: newTokenPage.referenceSymbol referenceSymbol: newTokenPage.referenceSymbol

View File

@ -295,13 +295,13 @@ StatusSectionLayout {
mintPanel.isFeeLoading = true mintPanel.isFeeLoading = true
return return
} }
mintPanel.errorText = qsTr("Unknown error") mintPanel.errorText = qsTr("Unknown error")
mintPanel.isFeeLoading = true mintPanel.isFeeLoading = true
} }
communityName: root.community.name communityName: root.community.name
tokensModel: root.community.communityTokens tokensModel: root.community.communityTokens
tokensModelWallet: root.rootStore.tokensModelWallet
layer1Networks: communityTokensStore.layer1Networks layer1Networks: communityTokensStore.layer1Networks
layer2Networks: communityTokensStore.layer2Networks layer2Networks: communityTokensStore.layer2Networks
testNetworks: communityTokensStore.testNetworks testNetworks: communityTokensStore.testNetworks

View File

@ -24,6 +24,7 @@ StatusScrollView {
property bool isAssetView: false property bool isAssetView: false
property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty property int validationMode: StatusInput.ValidationMode.OnlyWhenDirty
property var tokensModel property var tokensModel
property var tokensModelWallet
property TokenObject collectible: TokenObject { property TokenObject collectible: TokenObject {
@ -197,9 +198,11 @@ StatusScrollView {
return true return true
// Otherwise, no repeated names allowed: // Otherwise, no repeated names allowed:
return !SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) return (!SQUtils.ModelUtils.contains(root.tokensModel, "symbol", symbolInput.text) &&
!SQUtils.ModelUtils.contains(root.tokensModelWallet, "symbol", symbolInput.text))
} }
extraValidator.errorMessage: qsTr("You have used this token symbol before") extraValidator.errorMessage: SQUtils.ModelUtils.contains(root.tokensModelWallet, "symbol", symbolInput.text) ?
qsTr("This token symbol is already in use") : qsTr("You have used this token symbol before")
onTextChanged: { onTextChanged: {
const cursorPos = input.edit.cursorPosition const cursorPos = input.edit.cursorPosition
@ -395,6 +398,9 @@ StatusScrollView {
}, },
StatusValidator { StatusValidator {
id: extraValidatorItem id: extraValidatorItem
onErrorMessageChanged: {
customInput.validate();
}
} }
] ]
} }

View File

@ -54,6 +54,7 @@ QtObject {
property var accounts: walletSectionSendInst.accounts property var accounts: walletSectionSendInst.accounts
// Not Refactored Yet // Not Refactored Yet
// property var profileModelInst: profileModel // property var profileModelInst: profileModel
property var tokensModelWallet//TODO this is not available yet
property var contactStore: profileSectionStore.contactsStore property var contactStore: profileSectionStore.contactsStore
property var privacyStore: profileSectionStore.privacyStore property var privacyStore: profileSectionStore.privacyStore