From 4c24bdf2260f3596235954c9c430115c96079c01 Mon Sep 17 00:00:00 2001 From: goodmice Date: Thu, 14 Oct 2021 12:44:06 +0500 Subject: [PATCH] =?UTF-8?q?hotfix.=20CF2-75,=20CF2-76.=20=D0=94=D1=83?= =?UTF-8?q?=D0=B1=D0=BB=D0=B8=D0=BA=D0=B0=D1=86=D0=B8=D1=8F=20=D0=BA=D0=BE?= =?UTF-8?q?=D0=B4=D0=B0=20=D0=BE=D0=B1=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87?= =?UTF-8?q?=D0=B8=D0=BA=D0=BE=D0=B2=20=D1=83=D1=81=D1=82=D1=80=D0=B0=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/TelemetryView/index.jsx | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/pages/TelemetryView/index.jsx b/src/pages/TelemetryView/index.jsx index fbbe5bd..a8c3211 100644 --- a/src/pages/TelemetryView/index.jsx +++ b/src/pages/TelemetryView/index.jsx @@ -179,25 +179,14 @@ export default function TelemetryView({idWell}) { const options = timePeriodCollection.map((line) => ) - const handleDataSaub = (data) => { - if (data) { + const handleData = (state) => (data) => { + if (data && state) { data.forEach((_, idx) => { if (data[idx].rotorSpeed < 1) data[idx].rotorSpeed = 0; data[idx].blockSpeed = Math.abs(data[idx].blockSpeed) }) - setDataSaub(data) - } - } - - const handleDataSpin = (data) => { - if (data) { - data.forEach((_, idx) => { - if (data[idx].rotorSpeed < 1) - data[idx].rotorSpeed = 0; - data[idx].blockSpeed = Math.abs(data[idx].blockSpeed) - }) - setDataSpin(data) + state(data) } } @@ -206,14 +195,14 @@ export default function TelemetryView({idWell}) { async () => { const dataSaub = await TelemetryDataSaubService.getData(idWell, null, chartInterval) const dataSpin = await TelemetryDataSpinService.getData(idWell, null, chartInterval) - handleDataSaub(dataSaub) - handleDataSpin(dataSpin) + handleData(setDataSaub)(dataSaub) + handleData(setDataSpin)(dataSpin) }, setShowLoader, `Не удалось получить данные по скважине "${idWell}"`, ) - const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleDataSaub) - const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleDataSpin) + const unsubscribeSaub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${idWell}`, handleData(setDataSaub)) + const unsubscribeSpin = Subscribe('hubs/telemetry', 'ReceiveDataSpin', `well_${idWell}`, handleData(setDataSpin)) return () => { unsubscribeSaub() unsubscribeSpin()