From 6a4b14dfc6e7231c0a3c497d48926a860b4992c6 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 21 Aug 2021 14:31:01 +0200 Subject: [PATCH] Governance Bug Fixed. Reputation not loading while switching workspaces --- .../UI/Spaces/Design-Space/Workspace.js | 1 + .../Spaces/User-Profile-Space/UserProfile.js | 26 ++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js index d3fda57e7..ff1e6b7e8 100644 --- a/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Foundations/UI/Spaces/Design-Space/Workspace.js @@ -420,6 +420,7 @@ function newWorkspace() { thisObject.isInitialized = true UI.projects.governance.spaces.reportsSpace.reset() + UI.projects.governance.spaces.userProfileSpace.reset() await UI.projects.education.spaces.docsSpace.reset() await UI.projects.education.spaces.tutorialSpace.reset() diff --git a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js index 54cb070fd..55db38dc2 100644 --- a/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js +++ b/Projects/Governance/UI/Spaces/User-Profile-Space/UserProfile.js @@ -9,21 +9,14 @@ function newGovernanceUserProfileSpace() { physics: physics, draw: draw, getContainer: getContainer, + reset: reset, finalize: finalize, initialize: initialize } - thisObject.container = newContainer() - thisObject.container.initialize(MODULE_NAME) - thisObject.container.isDraggeable = false - let waitingForResponses = 0 let timer = 0 - thisObject.githubStars = new Map() - thisObject.githubWatchers = new Map() - thisObject.githubForks = new Map() - let reputationByAddress = new Map() return thisObject @@ -34,7 +27,13 @@ function newGovernanceUserProfileSpace() { Superalgos Repository. This will later be used to know which user profiles are participating at the Github Program. */ + thisObject.githubStars = new Map() + thisObject.githubWatchers = new Map() + thisObject.githubForks = new Map() + 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 */ @@ -95,6 +94,8 @@ function newGovernanceUserProfileSpace() { } if (tokenTransfers.length > 9000) { console.log('[WARN] The total amount of BSC SA Token transfers is above 9000. After 10k this method will need pagination or otherwise users will not get their reputation calculated correctly.') + } else { + console.log('[INFO] ' + tokenTransfers.length + ' reputation trasactions found at the blockchain. ') } waitingForResponses-- }).catch(function (err) { @@ -244,11 +245,18 @@ function newGovernanceUserProfileSpace() { function finalize() { thisObject.githubStars = undefined + thisObject.githubWatchers = undefined + thisObject.githubForks = undefined thisObject.container.finalize() thisObject.container = undefined } + function reset() { + finalize() + initialize() + } + function getContainer(point) { return undefined // since this space does not draw anything we return here @@ -341,7 +349,7 @@ function newGovernanceUserProfileSpace() { console.log(data) userProfile.payload.uiObject.setInfoMessage(data) userProfile.payload.blockchainTokens = Number(data.result) / 1000000000000000000 - userProfile.payload.reputation = Math.min(reputationByAddress.get(blockchainAccount.toLowerCase()) | 0, userProfile.payload.blockchainTokens) + userProfile.payload.reputation = Math.min(reputationByAddress.get(blockchainAccount.toLowerCase()) | 0, userProfile.payload.blockchainTokens) waitingForResponses-- }).catch(function (err) { const message = err.message + ' - ' + 'Can not access BSC SCAN servers.'