From fe52116a9be3552e98c18f26cc32631780d3e4a2 Mon Sep 17 00:00:00 2001 From: goodmice Date: Mon, 21 Nov 2022 10:58:02 +0500 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=BB=D1=83=D1=87=D1=88=D0=B5=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BF=D1=80=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D1=85=D0=BE=D0=B4=D0=B5=20=D0=B2=20=D0=B0=D1=80=D1=85=D0=B8?= =?UTF-8?q?=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Well/Telemetry/TelemetryView/index.jsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/pages/Well/Telemetry/TelemetryView/index.jsx b/src/pages/Well/Telemetry/TelemetryView/index.jsx index ea26a6d..d34d7e7 100644 --- a/src/pages/Well/Telemetry/TelemetryView/index.jsx +++ b/src/pages/Well/Telemetry/TelemetryView/index.jsx @@ -72,6 +72,8 @@ const makeSubjectSubsription = (subject$, handler) => { return () => subscribtion.unsubscribe() } +const getRowDate = (row) => row && isRawDate(row.date) ? new Date(row.date) : null + const TelemetryView = memo(() => { const [well, updateWell] = useWell() const [searchParams, setSearchParams] = useSearchParams() @@ -101,6 +103,10 @@ const TelemetryView = memo(() => { const dataSaub = normalizeData(data) const out = replace ? [...dataSaub] : [...prev, ...dataSaub] out.sort(dateSorter) + setLoadedDataRange({ + start: getRowDate(out.at(0)), + end: getRowDate(out.at(-1)), + }) return out }) }, []) @@ -116,8 +122,6 @@ const TelemetryView = memo(() => { const onWheel = useCallback((e) => { if (!archiveMode && e.deltaY < 0) { setArchiveMode(true) - setDataSaub([]) - setDataSpin([]) } else if (archiveMode) { setEndDate((prevEndDate) => { const offset = e.deltaY / 100 * chartInterval * 0.15 // сдвиг в 15% интервала @@ -127,7 +131,6 @@ const TelemetryView = memo(() => { const out = new Date(Math.max(firstPossibleDate, Math.min(nextEndDate, lastPossibleDate))) if (e.deltaY > 0 && +out >= lastPossibleDate) { // Автопереход к актуальным данным при прокручивании в самый низ setArchiveMode(false) - setLoadedDataRange(null) } return out }) @@ -209,7 +212,10 @@ const TelemetryView = memo(() => { if (data) { data.forEach(elm => elm.date = new Date(elm.date)) setDataSaub((prevDataSaub) => { - const newData = [...prevDataSaub, ...normalizeData(data)] + let newData = normalizeData(data) + if (+loadingStartDate > +loadedDataRange.start || (+loadingStartDate + loadingInterval * 1000) < +loadedDataRange.end) { + newData = [...prevDataSaub, ...newData] + } newData.sort(dateSorter) return cutData(newData, loadedStartDate, loadedEndDate) })