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)