@@ -23,35 +23,33 @@ export const collapseStringsAfterLengthAtom = atom<JsonViewerState['collapseStri
23
23
export const defaultInspectDepthAtom = atom < JsonViewerState [ 'defaultInspectDepth' ] | undefined > ( undefined )
24
24
export const objectSortKeysAtom = atom < JsonViewerState [ 'objectSortKeys' ] | undefined > ( undefined )
25
25
export const quotesOnKeysAtom = atom < JsonViewerState [ 'quotesOnKeys' ] | undefined > ( undefined )
26
- export const inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
27
26
export const hoverPathAtom = atom < JsonViewerState [ 'hoverPath' ] | null > ( null )
28
27
export const registryAtom = atom < TypeRegistryState [ 'registry' ] > ( [ ] )
29
28
29
+ const _inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
30
30
// TODO check: if memory leaks, add to last line of useEffect:
31
31
// return () => { atomFamily.remove ... // Anything in here is fired on component unmount }
32
- export const getInspectCacheAtom = atomFamily ( ( { path, nestedIndex } ) => atom (
32
+ export const inspectCacheAtom = atomFamily ( ( { path, nestedIndex } ) => atom (
33
33
( get ) => {
34
34
const target = nestedIndex === undefined
35
35
? path . join ( '.' )
36
36
: `${ path . join ( '.' ) } [${ nestedIndex } ]nt`
37
- return get ( inspectCacheAtom ) [ target ]
38
- }
39
- ) , deepEqual )
40
- export const setInspectCacheAtom = atom (
41
- ( get ) => get ( inspectCacheAtom ) ,
37
+ return get ( _inspectCacheAtom ) [ target ]
38
+ } ,
42
39
( get , set , { path, action, nestedIndex } ) => {
43
40
const target = nestedIndex === undefined
44
41
? path . join ( '.' )
45
42
: `${ path . join ( '.' ) } [${ nestedIndex } ]nt`
46
- const inspectCache = get ( inspectCacheAtom )
47
- return set ( inspectCacheAtom , {
43
+ const inspectCache = get ( _inspectCacheAtom )
44
+ return set ( _inspectCacheAtom , {
48
45
...inspectCache ,
49
46
[ target ] : typeof action === 'function'
50
47
? action ( inspectCache [ target ] )
51
48
: action
52
49
} )
53
50
}
54
- )
51
+ ) , deepEqual )
52
+
55
53
export const setHoverAtom = atom (
56
54
( get ) => get ( hoverPathAtom ) ,
57
55
( _get , set , { path, nestedIndex } ) => {
0 commit comments