From 00ddb516857f603bb8d6ee90fb8b4748b22de7d2 Mon Sep 17 00:00:00 2001 From: Roland Schilter Date: Fri, 21 Jul 2017 16:34:36 +0200 Subject: [PATCH] Fix Pods number in graph not updating (minor label) (#2728) By only caching layout values (x, y, rank) Fixes #2401. --- client/app/scripts/charts/nodes-layout.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/app/scripts/charts/nodes-layout.js b/client/app/scripts/charts/nodes-layout.js index a67b18840..34db4c5d0 100644 --- a/client/app/scripts/charts/nodes-layout.js +++ b/client/app/scripts/charts/nodes-layout.js @@ -1,6 +1,7 @@ import dagre from 'dagre'; import debug from 'debug'; import { fromJS, Map as makeMap, Set as ImmSet } from 'immutable'; +import pick from 'lodash/pick'; import { NODE_BASE_SIZE, EDGE_WAYPOINTS_CAP } from '../constants/styles'; import { EDGE_ID_SEPARATOR } from '../constants/naming'; @@ -487,7 +488,10 @@ export function doLayout(immNodes, immEdges, opts) { // cache results cache.cachedLayout = layout; - cache.nodeCache = cache.nodeCache.merge(layout.nodes); + // only cache layout-related properties + // NB: These properties must be immutable wrt a given node because properties of updated nodes + // will be overwritten with the cached values, see copyLayoutProperties() + cache.nodeCache = cache.nodeCache.merge(layout.nodes.map(n => fromJS(pick(n.toJS(), ['x', 'y', 'rank'])))); cache.edgeCache = cache.edgeCache.merge(layout.edges); }