setLoader(false) перенесён в вызов у промиса для ActiveMessage и TelemetryView

This commit is contained in:
Alexey 2021-07-29 15:46:59 +05:00
parent e350c4e4cd
commit c5abb21e6d
2 changed files with 8 additions and 15 deletions

View File

@ -54,18 +54,15 @@ export default function ActiveMessagesOnline({idWell}) {
useEffect(() => { useEffect(() => {
setLoader(true) setLoader(true)
let promiseMessages = MessageService.getMessage(idWell) MessageService.getMessage(idWell)
.then(handleReceiveMessages) .then(handleReceiveMessages)
.catch((ex) => { .catch((ex) => {
notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error') notify(`Не удалось загрузить сообщения по скважине "${idWell}"`, 'error')
console.log(ex) console.log(ex)
}) })
.finally(()=>setLoader(false))
Promise.all([promiseMessages]).then(()=>setLoader(false)) return Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages)
let unSubscribeMessagesHub = Subscribe('hubs/telemetry','ReceiveMessages', `well_${idWell}`, handleReceiveMessages)
return () => {
unSubscribeMessagesHub()
}
}, [idWell]) }, [idWell])
return (<LoaderPortal show={loader}> return (<LoaderPortal show={loader}>

View File

@ -142,20 +142,16 @@ export default function TelemetryView(props) {
useEffect(() => { useEffect(() => {
setLoader(true) setLoader(true)
let promiseData = DataService.getData(id) DataService.getData(id)
.then(handleReceiveDataSaub) .then(handleReceiveDataSaub)
.catch((ex) => { .catch((ex) => {
notify(`Не удалось загрузить данные по скважине "${id}"`, 'error') notify(`Не удалось загрузить данные по скважине "${id}"`, 'error')
console.log(ex) console.log(ex)
}) })
.finally(()=>setLoader(false))
Promise.all([promiseData]).then(()=>setLoader(false)) return Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub)
}, [id])
let unSubscribeDataSaubHub = Subscribe('hubs/telemetry', 'ReceiveDataSaub', `well_${id}`, handleReceiveDataSaub)
return () => {
unSubscribeDataSaubHub()
}
}, [id]);
useEffect(() => { useEffect(() => {
setLoader(true) setLoader(true)
@ -163,7 +159,7 @@ export default function TelemetryView(props) {
.then(handleReceiveDataSaub) .then(handleReceiveDataSaub)
.catch(error => console.error(error)) .catch(error => console.error(error))
.finally(()=>setLoader(false)) .finally(()=>setLoader(false))
}, [id, chartInterval]); }, [id, chartInterval])
const colSpan = 24 / (paramsGroups.length) const colSpan = 24 / (paramsGroups.length)