Skip to content

Commit 48a32e8

Browse files
feat: prefer loading ft spectra and auto processing FID
refactor: remove appendFilter utility
1 parent 42a38af commit 48a32e8

6 files changed

Lines changed: 161 additions & 224 deletions

File tree

package-lock.json

Lines changed: 75 additions & 45 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"dependencies": {
1515
"@emotion/react": "^11.11.1",
1616
"filelist-utils": "^1.10.2",
17-
"nmr-load-save": "^0.21.0",
18-
"nmr-processing": "^11.2.0",
17+
"nmr-load-save": "^0.23.2",
18+
"nmr-processing": "^11.5.0",
1919
"nmrium": "0.44.1-pre.1696502379",
2020
"react-science": "^0.28.1",
2121
"vite-plugin-pwa": "^0.16.7"

src/events/types.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ interface DataChange {
4040
type EventData<T extends EventType> = T extends 'data-change'
4141
? DataChange
4242
: T extends 'load'
43-
? LoadData
44-
: T extends 'action-request'
45-
? ActionRequest
46-
: T extends 'action-response'
47-
? ActionResponse
48-
: T extends 'error'
49-
? Error
50-
: never;
43+
? LoadData
44+
: T extends 'action-request'
45+
? ActionRequest
46+
: T extends 'action-response'
47+
? ActionResponse
48+
: T extends 'error'
49+
? Error
50+
: never;
5151
export type { EventType, EventData };

src/hooks/useLoadSpectra.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,25 @@ import {
44
readFromWebSource,
55
NmriumState,
66
CURRENT_EXPORT_VERSION,
7+
ParsingOptions,
78
} from 'nmr-load-save';
89
import { useCallback, useMemo, useState } from 'react';
910

1011
import events from '../events';
11-
import { appendFilters } from '../utilities/appendFilters';
1212
import { getFileNameFromURL } from '../utilities/getFileNameFromURL';
1313
import { isArrayOfString } from '../utilities/isArrayOfString';
1414

15+
const PARSING_OPTIONS: Partial<ParsingOptions> = {
16+
onLoadProcessing: { autoProcessing: true },
17+
sourceSelector: { general: { dataSelection: 'preferFT' } },
18+
};
19+
1520
async function loadSpectraFromFiles(files: File[]) {
1621
const fileCollection = await fileCollectionFromFiles(files);
1722

1823
const {
1924
nmriumState: { data },
20-
} = await read(fileCollection);
25+
} = await read(fileCollection, PARSING_OPTIONS);
2126
return data;
2227
}
2328

@@ -33,7 +38,7 @@ async function loadSpectraFromURLs(urls: string[]) {
3338
return { relativePath: path, baseURL: refURL.origin };
3439
}, []);
3540

36-
const { data } = await readFromWebSource({ entries });
41+
const { data } = await readFromWebSource({ entries }, PARSING_OPTIONS);
3742
return data;
3843
}
3944

@@ -50,18 +55,12 @@ export function useLoadSpectra() {
5055
if ('urls' in options) {
5156
if (isArrayOfString(options.urls)) {
5257
const result = await loadSpectraFromURLs(options.urls);
53-
if (result?.spectra) {
54-
appendFilters(result?.spectra);
55-
}
5658
setData(result as NMRiumData);
5759
} else {
5860
throw new Error('The input must be a valid urls array of string[]');
5961
}
6062
} else if ('files' in options) {
6163
const result = await loadSpectraFromFiles(options.files);
62-
if (result?.spectra) {
63-
appendFilters(result?.spectra);
64-
}
6564
setData(result as NMRiumData);
6665
}
6766
} catch (error: unknown) {

0 commit comments

Comments
 (0)