Skip to content

Commit

Permalink
fix: refresh 2d domain
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-musallam committed Dec 3, 2024
1 parent 3568123 commit e6bd8bf
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/component/2d/ft/FTContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function FTContainer(props: FTContainerProps) {

const activeSpectrum = useSpectrum();

if (!isFt2DSpectrum(activeSpectrum)) {
if (activeSpectrum && !isFt2DSpectrum(activeSpectrum)) {
return null;
}

Expand Down
9 changes: 5 additions & 4 deletions src/component/reducer/actions/SpectraActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,10 +399,11 @@ function handleChangeActiveSpectrum(
* not refresh the y domain if the next and previous selected spectra have Ft or we do not have previous or next active spectra
*/
const refreshDomain =
previousActiveSpectraHasFT !== newActiveSpectraHasFT &&
spectra &&
spectra?.length > 0 &&
spectraIds?.length > 0;
previousActiveSpectraHasFT === undefined ||
(previousActiveSpectraHasFT !== newActiveSpectraHasFT &&
spectra &&
spectra?.length > 0 &&
spectraIds?.length > 0);

/**
* if the active spectrum not is FID then do not refresh the domain and the mode when the first time you activate spectrum
Expand Down
2 changes: 1 addition & 1 deletion src/data/data1d/Spectrum1D/isSpectrum1D.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Spectrum, Spectrum1D } from 'nmr-load-save';

export function isSpectrum1D(spectrum: Spectrum): spectrum is Spectrum1D {
return spectrum.info.dimension === 1;
return spectrum && spectrum.info.dimension === 1;
}

export function isFid1DSpectrum(spectrum: Spectrum): spectrum is Spectrum1D {
Expand Down
2 changes: 1 addition & 1 deletion src/data/data2d/Spectrum2D/isSpectrum2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { NmrData2D, NmrData2DFid, NmrData2DFt } from 'cheminfo-types';
import type { Spectrum, Spectrum2D } from 'nmr-load-save';

export function isSpectrum2D(spectrum: Spectrum): spectrum is Spectrum2D {
return spectrum.info.dimension === 2;
return spectrum && spectrum.info.dimension === 2;
}

export function isFt2DData(data: NmrData2D): data is NmrData2DFt {
Expand Down

0 comments on commit e6bd8bf

Please sign in to comment.