@@ -23,35 +23,33 @@ export const collapseStringsAfterLengthAtom = atom<JsonViewerState['collapseStri
2323export const defaultInspectDepthAtom = atom < JsonViewerState [ 'defaultInspectDepth' ] | undefined > ( undefined )
2424export const objectSortKeysAtom = atom < JsonViewerState [ 'objectSortKeys' ] | undefined > ( undefined )
2525export const quotesOnKeysAtom = atom < JsonViewerState [ 'quotesOnKeys' ] | undefined > ( undefined )
26- export const inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
2726export const hoverPathAtom = atom < JsonViewerState [ 'hoverPath' ] | null > ( null )
2827export const registryAtom = atom < TypeRegistryState [ 'registry' ] > ( [ ] )
2928
29+ const _inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
3030// TODO check: if memory leaks, add to last line of useEffect:
3131// 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 (
3333 ( get ) => {
3434 const target = nestedIndex === undefined
3535 ? path . join ( '.' )
3636 : `${ 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+ } ,
4239 ( get , set , { path, action, nestedIndex } ) => {
4340 const target = nestedIndex === undefined
4441 ? path . join ( '.' )
4542 : `${ path . join ( '.' ) } [${ nestedIndex } ]nt`
46- const inspectCache = get ( inspectCacheAtom )
47- return set ( inspectCacheAtom , {
43+ const inspectCache = get ( _inspectCacheAtom )
44+ return set ( _inspectCacheAtom , {
4845 ...inspectCache ,
4946 [ target ] : typeof action === 'function'
5047 ? action ( inspectCache [ target ] )
5148 : action
5249 } )
5350 }
54- )
51+ ) , deepEqual )
52+
5553export const setHoverAtom = atom (
5654 ( get ) => get ( hoverPathAtom ) ,
5755 ( _get , set , { path, nestedIndex } ) => {
0 commit comments