From 670827f651ad20159bae0e8d2fddbd35868ed618 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 21 Nov 2019 16:12:40 +0100 Subject: [PATCH] Bug Fixed, layers not appearing --- Panels/ProductsPanel.js | 62 ++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/Panels/ProductsPanel.js b/Panels/ProductsPanel.js index 12d4d976a..32f500524 100644 --- a/Panels/ProductsPanel.js +++ b/Panels/ProductsPanel.js @@ -286,12 +286,19 @@ function newProductsPanel () { for (let n = 0; n < tradingBotInstances.length; n++) { let tradingBotInstance = tradingBotInstances[n] let code - try { - code = JSON.parse(tradingBotInstance.code) - } catch (err) { - // if we can not parse this, then we ignore this trading engine. - } - if (code !== undefined) { + let instanceBot + let instanceTeam + + for (let m = 0; m < tradingBotInstance.processes.length; m++) { + let process = tradingBotInstance.processes[m] + try { + code = JSON.parse(process.payload.referenceParent.payload.parentNode.code) + instanceBot = code.codeName + code = JSON.parse(process.payload.referenceParent.payload.parentNode.payload.parentNode.code) + instanceTeam = code.codeName + } catch (err) { + continue + } for (let i = 0; i < ecosystem.devTeams.length; i++) { let devTeam = ecosystem.devTeams[i] @@ -299,37 +306,34 @@ function newProductsPanel () { let bot = devTeam.bots[j] if (bot.type !== 'Trading Bot Instance') { continue } - if (devTeam.codeName === code.team && bot.codeName === code.bot) { + if (devTeam.codeName === instanceTeam && bot.codeName === instanceBot) { /* We found an instance of the same Trading we are currently looking at. Next thing to do is to see its layers to see if we can match it with the current product. */ - for (let m = 0; m < tradingBotInstance.processes.length; m++) { - let process = tradingBotInstance.processes[m] - if (process.session !== undefined) { - if (process.session.layerManager !== undefined) { - let layerManager = process.session.layerManager + if (process.session !== undefined) { + if (process.session.layerManager !== undefined) { + let layerManager = process.session.layerManager - if (bot.products !== undefined) { - for (let k = 0; k < bot.products.length; k++) { - let product = bot.products[k] + if (bot.products !== undefined) { + for (let k = 0; k < bot.products.length; k++) { + let product = bot.products[k] - for (let p = 0; p < layerManager.layers.length; p++) { - let layer = layerManager.layers[p] - let layerCode - try { - layerCode = JSON.parse(layer.code) - } catch (err) { + for (let p = 0; p < layerManager.layers.length; p++) { + let layer = layerManager.layers[p] + let layerCode + try { + layerCode = JSON.parse(layer.code) + } catch (err) { // if we can not parse this, then we ignore this trading engine. - } + } - if (product.codeName === layerCode.product) { + if (product.codeName === layerCode.product) { /* We have a layer that is matching the current product */ - let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id - let cardFound = removeFromLocalProductCards(cardCode) - if (cardFound !== true) { - productCard = addProductCard(devTeam, bot, product, process.session) - onProductCardStatusChanged(productCard) - } + let cardCode = exchange + '-' + market.assetB + '/' + market.assetA + '-' + devTeam.codeName + '-' + bot.codeName + '-' + product.codeName + '-' + process.session.id + let cardFound = removeFromLocalProductCards(cardCode) + if (cardFound !== true) { + productCard = addProductCard(devTeam, bot, product, process.session) + onProductCardStatusChanged(productCard) } } }