Skip to content

Commit

Permalink
chore: pass logger to filter for time consuming information
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Nov 23, 2024
1 parent 7f6b32d commit 9a5936a
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 102 deletions.
103 changes: 47 additions & 56 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"multiplet-analysis": "^2.1.2",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^2.0.4",
"nmr-processing": "^14.0.3",
"nmr-processing": "14.0.4-pre.1732331477",
"nmredata": "^0.9.11",
"numeral": "^2.0.6",
"openchemlib": "^8.17.0",
Expand Down
5 changes: 5 additions & 0 deletions src/component/EventsTrackers/KeysListenerTracker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useAssignmentData } from '../assignment/AssignmentsContext.js';
import { useChartData } from '../context/ChartContext.js';
import { useDispatch } from '../context/DispatchContext.js';
import { useLoader } from '../context/LoaderContext.js';
import { useLogger } from '../context/LoggerContext.js';
import { usePreferences } from '../context/PreferencesContext.js';
import { useToaster } from '../context/ToasterContext.js';
import type { AlertButton } from '../elements/Alert.js';
Expand Down Expand Up @@ -83,6 +84,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
return displayerMode === '1D' && data && data.length > 0;
}, [data, displayerMode]);

const { logger } = useLogger();
const deleteHandler = useCallback(
async (sourceData) => {
const { type, extra } = sourceData;
Expand Down Expand Up @@ -176,6 +178,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
type: 'DELETE_EXCLUSION_ZONE',
payload: {
zone,
logger,
},
});
hideLoading();
Expand All @@ -194,6 +197,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
payload: {
zone,
spectrumId: spectrumID,
logger,
},
});
hideLoading();
Expand Down Expand Up @@ -288,6 +292,7 @@ function KeysListenerTracker(props: KeysListenerTrackerProps) {
toaster,
dispatchPreferences,
activeTab,
logger,
],
);

Expand Down
1 change: 1 addition & 0 deletions src/component/loader/useLoadFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function useLoadFiles(onOpenMetaInformation?: (file: File) => void) {
containsNmrium,
parseMetaFileResult,
spectraColors,
logger,
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions src/component/main/NMRiumStateProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export default function NMRiumStateProvider(props: NMRiumStateProviderProps) {
},
});
}
dispatch({ type: 'INITIATE', payload: { nmriumState } });
dispatch({ type: 'INITIATE', payload: { nmriumState, logger } });
})
.catch((error: unknown) => {
dispatch({ type: 'SET_LOADING_FLAG', payload: { isLoading: false } });
Expand All @@ -129,7 +129,7 @@ export default function NMRiumStateProvider(props: NMRiumStateProviderProps) {
reportError(error);
});
}
}, [nmriumData, dispatch, dispatchPreferences]);
}, [nmriumData, dispatch, dispatchPreferences, logger]);
const { sortOptions } = useSortSpectra();

const spectra = useMemo(() => {
Expand Down
1 change: 1 addition & 0 deletions src/component/modal/LoadJCAMPModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { useForm } from 'react-hook-form';
import * as Yup from 'yup';

import { useDispatch } from '../context/DispatchContext.js';
import { useLogger } from '../context/LoggerContext.js';
import { useToaster } from '../context/ToasterContext.js';
import { Input2Controller } from '../elements/Input2Controller.js';
import type { LabelStyle } from '../elements/Label.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { MatrixFilter } from '../../../data/matrixGeneration.js';
import { getMatrixFilters } from '../../../data/matrixGeneration.js';
import { useChartData } from '../../context/ChartContext.js';
import { useDispatch } from '../../context/DispatchContext.js';
import { useLogger } from '../../context/LoggerContext.js';
import { usePreferences } from '../../context/PreferencesContext.js';
import type { GroupPaneStyle } from '../../elements/GroupPane.js';
import { GroupPane } from '../../elements/GroupPane.js';
Expand Down Expand Up @@ -124,6 +125,7 @@ function InnerMatrixGenerationPanel() {
activeTab,
);

const { logger } = useLogger();
const matrixOptions = getMatrixOptions(nucleusMatrixOptions.matrixOptions, {
from: originDomain.xDomain[0],
to: originDomain.xDomain[1],
Expand Down Expand Up @@ -152,7 +154,7 @@ function InnerMatrixGenerationPanel() {
function handleRemoveProcessing() {
dispatch({
type: 'DELETE_SPECTRA_FILTER',
payload: { filterName: signalProcessing.name },
payload: { filterName: signalProcessing.name, logger },
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { getFilterLabel } from '../../../../data/getFilterLabel.js';
import type { FilterEntry as BaseFilterEntry } from '../../../../data/types/common/FilterEntry.js';
import { useChartData } from '../../../context/ChartContext.js';
import { useDispatch } from '../../../context/DispatchContext.js';
import { useLogger } from '../../../context/LoggerContext.js';
import { useToaster } from '../../../context/ToasterContext.js';
import type { AlertButton } from '../../../elements/Alert.js';
import { useAlert } from '../../../elements/Alert.js';
Expand Down Expand Up @@ -62,14 +63,14 @@ function FilterElements(props: FilterElementsProps) {
} = props;
const { id, name, enabled } = filter;
const label = getFilterLabel(name);

const { logger } = useLogger();
function handleFilterCheck(id, event: React.ChangeEvent<HTMLInputElement>) {
const enabled = event.target.checked;
const hideLoading = toaster.showLoading({
message: `${enabled ? 'Enable' : 'Disable'} filter in progress`,
});
setTimeout(() => {
dispatch({ type: 'ENABLE_FILTER', payload: { id, enabled } });
dispatch({ type: 'ENABLE_FILTER', payload: { id, enabled, logger } });
hideLoading();
}, 0);
onEnableChange();
Expand All @@ -83,7 +84,10 @@ function FilterElements(props: FilterElementsProps) {
const hideLoading = await toaster.showAsyncLoading({
message: 'Delete filter process in progress',
});
dispatch({ type: 'DELETE_FILTER', payload: { id } });
dispatch({
type: 'DELETE_FILTER',
payload: { id, logger },
});
hideLoading();
},
intent: 'danger',
Expand All @@ -100,7 +104,7 @@ function FilterElements(props: FilterElementsProps) {
});
dispatch({
type: 'DELETE_SPECTRA_FILTER',
payload: { filterName: name },
payload: { filterName: name, logger },
});
hideLoading();
},
Expand Down
Loading

0 comments on commit 9a5936a

Please sign in to comment.