From c5abb21e6d548fdec2e8e5f8c7c038e4e5455372 Mon Sep 17 00:00:00 2001 From: Alexey Date: Thu, 29 Jul 2021 15:46:59 +0500 Subject: [PATCH] =?UTF-8?q?setLoader(false)=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BD=D0=B5=D1=81=D1=91=D0=BD=20=D0=B2=20=D0=B2=D1=8B=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=20=D1=83=20=D0=BF=D1=80=D0=BE=D0=BC=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=20=D0=B4=D0=BB=D1=8F=20ActiveMessage=20=D0=B8=20Telemetr?= =?UTF-8?q?yView?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ActiveMessagesOnline.jsx | 9 +++------ src/pages/TelemetryView.jsx | 14 +++++--------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/components/ActiveMessagesOnline.jsx b/src/components/ActiveMessagesOnline.jsx index fb7a818..768ba34 100644 --- a/src/components/ActiveMessagesOnline.jsx +++ b/src/components/ActiveMessagesOnline.jsx @@ -54,18 +54,15 @@ export default function ActiveMessagesOnline({idWell}) { useEffect(() => { setLoader(true) - let promiseMessages = MessageService.getMessage(idWell) + MessageService.getMessage(idWell) .then(handleReceiveMessages) .catch((ex) => { notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') console.log(ex) }) + .finally(()=>setLoader(false)) - Promise.all([promiseMessages]).then(()=>setLoader(false)) - let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) - return () => { - unSubscribeMessagesHub() - } + return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages) }, [idWell]) return ( diff --git a/src/pages/TelemetryView.jsx b/src/pages/TelemetryView.jsx index 193916a..bccc918 100644 --- a/src/pages/TelemetryView.jsx +++ b/src/pages/TelemetryView.jsx @@ -142,20 +142,16 @@ export default function TelemetryView(props) { useEffect(() => { setLoader(true) - let promiseData = DataService.getData(id) + DataService.getData(id) .then(handleReceiveDataSaub) .catch((ex) => { notify(`Не удалось загрузить данные по скважине "${id}"`, 'error') console.log(ex) }) + .finally(()=>setLoader(false)) - Promise.all([promiseData]).then(()=>setLoader(false)) - - let unSubscribeDataSaubHub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) - return () => { - unSubscribeDataSaubHub() - } - }, [id]); + return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub) + }, [id]) useEffect(() => { setLoader(true) @@ -163,7 +159,7 @@ export default function TelemetryView(props) { .then(handleReceiveDataSaub) .catch(error => console.error(error)) .finally(()=>setLoader(false)) - }, [id, chartInterval]); + }, [id, chartInterval]) const colSpan = 24 / (paramsGroups.length)