diff --git a/lib/client/index.js b/lib/client/index.js index 01b1dce60ea..8c5d22f5c82 100644 --- a/lib/client/index.js +++ b/lib/client/index.js @@ -468,6 +468,16 @@ client.load = function load (serverSettings, callback) { adjustCurrentSGVClasses(value, isCurrent); } + function mergeDeviceStatus (retro, ddata) { + var result = retro.map(x => Object.assign(x, ddata.find(y => y._id == x._id))); + + var missingInRetro = ddata.filter(y => !retro.find(x => x._id == y._id)); + + result.push(...missingInRetro); + + return result; + } + function updatePlugins (time) { //TODO: doing a clone was slow, but ok to let plugins muck with data? @@ -482,7 +492,7 @@ client.load = function load (serverSettings, callback) { var mergedStatuses = client.ddata.devicestatus; if (client.retro.data) { - mergedStatuses = _.merge({}, client.retro.data.devicestatus, client.ddata.devicestatus); + mergedStatuses = mergeDeviceStatus(client.retro.data.devicestatus, client.ddata.devicestatus); } var clonedData = _.clone(client.ddata);