From ff04b63194dadca97bb9e932d676d735fef09621 Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Tue, 30 Jun 2026 09:16:46 +0200 Subject: [PATCH 1/2] fix: do not look for matching signals if the spectrum does not exist --- src/component/panels/SummaryPanel/SummaryPanel.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/component/panels/SummaryPanel/SummaryPanel.tsx b/src/component/panels/SummaryPanel/SummaryPanel.tsx index 4ad1950e8..eaa7430b1 100644 --- a/src/component/panels/SummaryPanel/SummaryPanel.tsx +++ b/src/component/panels/SummaryPanel/SummaryPanel.tsx @@ -153,6 +153,9 @@ function SummaryPanel() { link.experimentID, true, ) as Spectrum2D; + + if (!spectrum) return false; + return findSignalMatch1D( spectrum, link, @@ -180,6 +183,9 @@ function SummaryPanel() { true, ) as Spectrum2D; // correlation is represented by a 2D signal + + if (!spectrum) return false; + if ( findSignalMatch2D( spectrum, @@ -201,6 +207,9 @@ function SummaryPanel() { link.experimentID, true, ) as Spectrum2D; + + if (!spectrum) return false; + return findSignalMatch2D( spectrum, link, From bbd2f3d8e8a7093356e13394327f0d3d3ac20826 Mon Sep 17 00:00:00 2001 From: hamed musallam Date: Tue, 30 Jun 2026 10:11:01 +0200 Subject: [PATCH 2/2] refactor: use type guard --- .../panels/SummaryPanel/SummaryPanel.tsx | 21 +++++++------------ 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/component/panels/SummaryPanel/SummaryPanel.tsx b/src/component/panels/SummaryPanel/SummaryPanel.tsx index eaa7430b1..8bf327fe4 100644 --- a/src/component/panels/SummaryPanel/SummaryPanel.tsx +++ b/src/component/panels/SummaryPanel/SummaryPanel.tsx @@ -10,6 +10,7 @@ import { getLinkDelta, getLinkDim } from 'nmr-correlation'; import { memo, useCallback, useMemo, useState } from 'react'; import { FaFlask, FaSlidersH } from 'react-icons/fa'; +import { isSpectrum2D } from '../../../data/data2d/Spectrum2D/isSpectrum2D.ts'; import { findRange, findSignal1D, @@ -148,13 +149,9 @@ function SummaryPanel() { // try to find a link which contains the belonging 2D signal in the spectra in view if ( correlation.link.some((link: Link) => { - const spectrum = findSpectrum( - spectraData, - link.experimentID, - true, - ) as Spectrum2D; + const spectrum = findSpectrum(spectraData, link.experimentID, true); - if (!spectrum) return false; + if (!isSpectrum2D(spectrum)) return false; return findSignalMatch1D( spectrum, @@ -181,10 +178,10 @@ function SummaryPanel() { spectraData, firstLink2D.experimentID, true, - ) as Spectrum2D; + ); // correlation is represented by a 2D signal - if (!spectrum) return false; + if (!isSpectrum2D(spectrum)) return false; if ( findSignalMatch2D( @@ -202,13 +199,9 @@ function SummaryPanel() { // try to find a link which contains the belonging 2D signal in the spectra in view else if ( correlation.link.some((link: any) => { - const spectrum = findSpectrum( - spectraData, - link.experimentID, - true, - ) as Spectrum2D; + const spectrum = findSpectrum(spectraData, link.experimentID, true); - if (!spectrum) return false; + if (!isSpectrum2D(spectrum)) return false; return findSignalMatch2D( spectrum,