Skip to content

Commit

Permalink
fix: Bug when drag / drop second NMRium file
Browse files Browse the repository at this point in the history
close #1421
  • Loading branch information
hamed-musallam committed Mar 11, 2022
1 parent 456e80a commit 08ada51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/component/1d/FooterBanner.tsx
Expand Up @@ -192,7 +192,7 @@ function FooterBannerInner({

const MemoizedFooterBanner = memo(FooterBannerInner);

const emptyData = { info: {}, data: {} };
const emptyData = { info: {}, data: null };

export default function FooterBanner() {
const { margin, width, height, activeSpectrum, activeTab } = useChartData();
Expand Down
7 changes: 7 additions & 0 deletions src/component/reducer/actions/LoadActions.ts
Expand Up @@ -11,6 +11,11 @@ import { State } from '../Reducer';
import { changeSpectrumVerticalAlignment } from './PreferencesActions';
import { setActiveTab } from './ToolsActions';

function resetState(draft: Draft<State>) {
draft.activeSpectrum = null;
draft.activeTab = '';
draft.tabActiveSpectrum = {};
}
function setIsLoading(draft: Draft<State>, isLoading: boolean) {
draft.isLoading = isLoading;
}
Expand Down Expand Up @@ -125,6 +130,7 @@ function loadJcampFile(draft: Draft<State>, actions) {
}

function handleLoadJsonFile(draft: Draft<State>, action) {
resetState(draft);
setData(draft, action.payload);
const preferences = action.payload?.preferences || {};
setActiveTab(draft, { tab: preferences?.activeTab || '' });
Expand Down Expand Up @@ -153,6 +159,7 @@ function handleLoadZIPFile(draft: Draft<State>, action) {
}

function handleLoadNmredata(draft: Draft<State>, action) {
resetState(draft);
setData(draft, action.payload);
setActiveTab(draft);
changeSpectrumVerticalAlignment(draft, { align: 'auto-check' });
Expand Down

0 comments on commit 08ada51

Please sign in to comment.