From 18640d7ddc3f67d839f3f6901a401206d74acae4 Mon Sep 17 00:00:00 2001 From: Connor Hudson Date: Wed, 6 Jun 2018 15:54:12 -0400 Subject: [PATCH] use mergeWith in requestAddMonitor, requestUpdateMonitor So undefined values don't overwrite defined ones --- src/engine/runtime.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index ab38955e4..5562ed9db 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -1522,7 +1522,17 @@ class Runtime extends EventEmitter { * @param {!MonitorRecord} monitor Monitor to add. */ requestAddMonitor (monitor) { - this._monitorState = this._monitorState.set(monitor.get('id'), monitor); + const id = monitor.get('id'); + if (this._monitorState.has(id)) { + this._monitorState = this._monitorState.set(id, this._monitorState.get(id).mergeWith((prev, next) => { + if (!next) { + return prev; + } + return next; + }, monitor)); + } else { + this._monitorState = this._monitorState.set(id, monitor); + } } /** @@ -1536,7 +1546,12 @@ class Runtime extends EventEmitter { const id = monitor.get('id'); if (this._monitorState.has(id)) { this._monitorState = - this._monitorState.set(id, this._monitorState.get(id).merge(monitor)); + this._monitorState.set(id, this._monitorState.get(id).mergeWith((prev, next) => { + if (!next) { + return prev; + } + return next; + }, monitor)); } }