From e1836ec8b46df287372a855c32298b4cf38dbfe8 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 Sep 2021 13:31:16 +0200 Subject: [PATCH] Recognize Governance Project Node as trigger for the workspace to be considered a Governance Workspace --- .../Spaces/User-Profile-Space/UserProfile.js | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js index d37d0f684..b851a6f82 100644 --- a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js +++ b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js @@ -23,6 +23,11 @@ function newGovernanceUserProfileSpace() { return thisObject function initialize() { + /* + If the workspace is not related to governance, then we exit the Intialize Function + */ + let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Governance Project') + if (governanceProject === undefined) { return } /* Here we will run the distribution process, that in turn will run all the programs. */ @@ -40,11 +45,8 @@ function newGovernanceUserProfileSpace() { thisObject.container = newContainer() thisObject.container.initialize(MODULE_NAME) thisObject.container.isDraggeable = false - /* - If the workspace is not related to governance, then we exit the Intialize Function - */ + let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile') - if (userProfiles.length === 0) { return } /* We are going to collapse all User Profiles to save processing resources at the UI */ @@ -330,10 +332,14 @@ function newGovernanceUserProfileSpace() { function physics() { if (UI.projects.foundations.spaces.designSpace.workspace === undefined) { return } /* + If the workspace is not related to governance, then we exit the Intialize Function + */ + let governanceProject = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('Governance Project') + if (governanceProject === undefined) { return } + /* Load the user profiles with Token Power. */ let userProfiles = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadsByNodeType('User Profile') - if (waitingForResponses !== 0) { return } /* We will get all the user Profiles tokens from the blockchain, making a call every 5 seconds so as not to exceed the rate limit. @@ -368,7 +374,7 @@ function newGovernanceUserProfileSpace() { userProfile.payload.uiObject.setErrorMessage( 'Call via HTTP Interface failed.', UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR - ) + ) return } @@ -379,7 +385,7 @@ function newGovernanceUserProfileSpace() { userProfile.payload.uiObject.setErrorMessage( 'Call to WEB3 Server failed. ' + response.error, UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR - ) + ) console.log('Call to WEB3 Server failed. ' + response.error) return } @@ -411,7 +417,7 @@ function newGovernanceUserProfileSpace() { } else { userProfile.payload.uiObject.setInfoMessage(data, UI.projects.governance.globals.designer.SET_INFO_COUNTER_FACTOR - ) + ) userProfile.payload.blockchainTokens = Number(data.result) / 1000000000000000000 userProfile.payload.reputation = Math.min(reputationByAddress.get(blockchainAccount.toLowerCase()) | 0, userProfile.payload.blockchainTokens) } @@ -422,7 +428,7 @@ function newGovernanceUserProfileSpace() { if (userProfile.payload !== undefined) { userProfile.payload.uiObject.setErrorMessage(message, UI.projects.governance.globals.designer.SET_ERROR_COUNTER_FACTOR - ) + ) } waitingForResponses-- });