From 5e9e7abf27218f353613738ccf8ea40a1be4a0d0 Mon Sep 17 00:00:00 2001 From: Erkan Karabulut <karabulut@fortiss.org> Date: Wed, 23 Feb 2022 09:32:55 +0100 Subject: [PATCH] fix device observation deletion method --- tsmatch_client/src/reducer/observation.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tsmatch_client/src/reducer/observation.js b/tsmatch_client/src/reducer/observation.js index 67b74a2..0de1cb7 100644 --- a/tsmatch_client/src/reducer/observation.js +++ b/tsmatch_client/src/reducer/observation.js @@ -28,11 +28,15 @@ const observation = (state = initialState, action) => { }); break; case 'REMOVE_DEVICE_OBSERVATIONS': - state.observationList.forEach(function (observation) { - if (observation.sensorIds.includes(action.deviceId)){ + let counter = 0; + while (counter < state.observationList.length) { + let observation = state.observationList[counter]; + if (observation.sensorIds.includes(action.deviceId)) { state.observationList.splice(state.observationList.indexOf(observation), 1); + } else { + counter++; } - }) + } } return {observationList: state.observationList}; -- GitLab