fix(DisplayNameValidation): Integrate duplicate display name in joined communities

This commit is contained in:
Alex Jbanca 2024-03-12 17:03:41 +02:00 committed by Alex Jbanca
parent 2f7572a3f4
commit 4ca7e9b32d
3 changed files with 21 additions and 11 deletions

View File

@ -100,11 +100,6 @@ QtObject {
return root.communitiesModuleInst.getCommunityPublicKeyFromPrivateKey(privateKey);
}
// Returns true if the provided displayName occurs in community members
function isDisplayNameDupeOfCommunityMember(displayName) {
root.communitiesModuleInst.isDisplayNameDupeOfCommunityMember(displayName)
}
function requestCommunityInfo(communityKey, shardCluster, shardIndex, importing = false) {
const publicKey = Utils.isCompressedPubKey(communityKey)
? Utils.changeCommunityKeyCompression(communityKey)

View File

@ -562,13 +562,12 @@ QtObject {
name: "isAliasValidator"
validate: function (t) { return !Utils.isAlias(t) }
errorMessage: qsTr("Adjective-animal Display Name formats are not allowed")
},
StatusValidator {
name: "isDuplicateInComunitiesValidator"
validate: function(t) { return !Utils.isDisplayNameDupeOfCommunityMember(t) }
errorMessage: qsTr("This Display Name is already in use in one of your joined communities")
}
// https://github.com/status-im/status-desktop/issues/13434
// StatusValidator {
// name: "isDuplicateInComunitiesValidator"
// validate: function(t) { return !globalUtils.isDuplicatedInComunities(t) }
// errorMessage: qsTr("This Display Name is already in use in one of your joined communities")
// }
]
}

View File

@ -962,4 +962,20 @@ QtObject {
function addTimestampToURL(url) {
return globalUtilsInst.addTimestampToURL(url)
}
// Returns true if the provided displayName occurs in community members
function isDisplayNameDupeOfCommunityMember(displayName) {
if (!communitiesModuleInst)
return false
if (displayName === "")
return false
const myDisplayName = Global.userProfile ? Global.userProfile.name : ""
if (displayName === myDisplayName)
return false
return communitiesModuleInst.isDisplayNameDupeOfCommunityMember(displayName)
}
}