|
1 | | -import { NMRiumPreferences, NMRiumWorkspace } from 'nmrium'; |
| 1 | +import { WorkspacePreferences } from 'nmr-load-save'; |
| 2 | +import { NMRiumWorkspace } from 'nmrium'; |
2 | 3 | import { useLayoutEffect, useState } from 'react'; |
3 | 4 |
|
4 | 5 | export function usePreferences() { |
5 | 6 | const [configuration, setConfiguration] = useState<{ |
6 | | - preferences: any; |
| 7 | + preferences: WorkspacePreferences | undefined; |
7 | 8 | workspace: NMRiumWorkspace | undefined; |
8 | | - }>({ preferences: {}, workspace: undefined }); |
| 9 | + }>({ preferences: undefined, workspace: undefined }); |
9 | 10 |
|
10 | 11 | useLayoutEffect(() => { |
11 | 12 | const { href } = window.location; |
12 | 13 | const parameters = new URL(href).searchParams; |
13 | 14 |
|
14 | | - let preferences: any | undefined; |
| 15 | + let preferences: WorkspacePreferences | undefined; |
15 | 16 | let workspace: NMRiumWorkspace | undefined; |
16 | 17 |
|
17 | 18 | if (parameters.has('workspace')) { |
18 | 19 | workspace = parameters.get('workspace') as NMRiumWorkspace; |
19 | 20 | } |
20 | 21 | if (parameters.has('preferences')) { |
21 | | - preferences = JSON.parse( |
22 | | - parameters.get('preferences') || '', |
23 | | - ) as NMRiumPreferences; |
| 22 | + preferences = JSON.parse(parameters.get('preferences') || ''); |
24 | 23 | } |
25 | 24 | setConfiguration({ preferences, workspace }); |
26 | 25 | }, []); |
|
0 commit comments