From 833c27ef21905d4939f695da0a15c1fdd6551f48 Mon Sep 17 00:00:00 2001 From: Connor Hudson Date: Thu, 7 Jun 2018 11:24:55 -0400 Subject: [PATCH] Remove debug comments, tweak logic for monitor data merging --- src/engine/runtime.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index cdfa8be5e..74f2623d7 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1524,8 +1524,9 @@ class Runtime extends EventEmitter { requestAddMonitor (monitor) { const id = monitor.get('id'); if (this._monitorState.has(id)) { + // Use mergeWith here to prevent undefined values from overwriting existing ones this._monitorState = this._monitorState.set(id, this._monitorState.get(id).mergeWith((prev, next) => { - if (!next) { + if (typeof next === 'undefined' || next === null) { return prev; } return next; @@ -1546,8 +1547,9 @@ class Runtime extends EventEmitter { const id = monitor.get('id'); if (this._monitorState.has(id)) { this._monitorState = + // Use mergeWith here to prevent undefined values from overwriting existing ones this._monitorState.set(id, this._monitorState.get(id).mergeWith((prev, next) => { - if (!next) { + if (typeof next === 'undefined' || next === null) { return prev; } return next; @@ -1561,8 +1563,6 @@ class Runtime extends EventEmitter { * @param {!string} monitorId ID of the monitor to remove. */ requestRemoveMonitor (monitorId) { - // this._monitorState = this._monitorState.delete(monitorId); - // TODO is this performant? if (this._monitorState.has(monitorId)) { this._monitorState = this._monitorState.set( monitorId, this._monitorState.get(monitorId).merge({visible: false})