fix(@desktop/communities): Fix enabling/disabling mint button

Fix #12370
This commit is contained in:
Michal Iskierko 2023-10-10 10:47:03 +02:00 committed by Michał Iskierko
parent 424da13346
commit 4bd3d672c6
1 changed files with 27 additions and 19 deletions

View File

@ -557,6 +557,10 @@ StatusSectionLayout {
StatusQUtils.ModelChangeTracker {
id: tokensModelChangesTracker
Component.onCompleted: {
updateOwnerAndTMasterProperties()
}
// Owner and TMaster token deployment states
property bool isOwnerTokenDeployed: false
property bool isTMasterTokenDeployed: false
@ -571,6 +575,28 @@ StatusSectionLayout {
StatusQUtils.ModelUtils.contains(model, "privilegesLevel", Constants.TokenPrivilegesLevel.TMaster)
}
function updateOwnerAndTMasterProperties() {
// It will update property to know if Owner and TMaster token items have been added into the tokens list.
ownerOrTMasterTokenItemsExist = checkIfPrivilegedTokenItemsExist()
if(!ownerOrTMasterTokenItemsExist)
return
// It monitors the deployment:
if(!isOwnerTokenDeployed) {
isOwnerTokenDeployed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Failed)
}
if(!isTMasterTokenDeployed) {
isTMasterTokenDeployed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Completed)
isTMasterTokenFailed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Failed)
}
// Not necessary to track more changes since privileged tokens have been correctly deployed.
if(isOwnerTokenDeployed && isTMasterTokenDeployed)
tokensModelChangesTracker.enabled = false
}
function reviewTokenDeployState(isOwner, deployState) {
const privileges = isOwner ? Constants.TokenPrivilegesLevel.Owner : Constants.TokenPrivilegesLevel.TMaster
const index = StatusQUtils.ModelUtils.indexOf(model, "privilegesLevel", privileges)
@ -591,25 +617,7 @@ StatusSectionLayout {
model: root.community.communityTokens
onRevisionChanged: {
// It will update property to know if Owner and TMaster token items have been added into the tokens list.
ownerOrTMasterTokenItemsExist = checkIfPrivilegedTokenItemsExist()
if(!ownerOrTMasterTokenItemsExist)
return
// It monitors the deployment:
if(!isOwnerTokenDeployed) {
isOwnerTokenDeployed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Completed)
isOwnerTokenFailed = reviewTokenDeployState(true, Constants.ContractTransactionStatus.Failed)
}
if(!isTMasterTokenDeployed) {
isTMasterTokenDeployed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Completed)
isTMasterTokenFailed = reviewTokenDeployState(false, Constants.ContractTransactionStatus.Failed)
}
// Not necessary to track more changes since privileged tokens have been correctly deployed.
if(isOwnerTokenDeployed && isTMasterTokenDeployed)
tokensModelChangesTracker.enabled = false
updateOwnerAndTMasterProperties()
}
}