@@ -22,35 +22,33 @@ export const collapseStringsAfterLengthAtom = atom<JsonViewerState['collapseStri
2222export const defaultInspectDepthAtom = atom < JsonViewerState [ 'defaultInspectDepth' ] | undefined > ( undefined )
2323export const objectSortKeysAtom = atom < JsonViewerState [ 'objectSortKeys' ] | undefined > ( undefined )
2424export const quotesOnKeysAtom = atom < JsonViewerState [ 'quotesOnKeys' ] | undefined > ( undefined )
25- export const inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
2625export const hoverPathAtom = atom < JsonViewerState [ 'hoverPath' ] | null > ( null )
2726export const registryAtom = atom < TypeRegistryState [ 'registry' ] > ( [ ] )
2827
28+ const _inspectCacheAtom = atom < JsonViewerState [ 'inspectCache' ] > ( { } )
2929// TODO check: if memory leaks, add to last line of useEffect:
3030// return () => { atomFamily.remove ... // Anything in here is fired on component unmount }
31- export const getInspectCacheAtom = atomFamily ( ( { path, nestedIndex } ) => atom (
31+ export const inspectCacheAtom = atomFamily ( ( { path, nestedIndex } ) => atom (
3232 ( get ) => {
3333 const target = nestedIndex === undefined
3434 ? path . join ( '.' )
3535 : `${ path . join ( '.' ) } [${ nestedIndex } ]nt`
36- return get ( inspectCacheAtom ) [ target ]
37- }
38- ) , deepEqual )
39- export const setInspectCacheAtom = atom (
40- ( get ) => get ( inspectCacheAtom ) ,
36+ return get ( _inspectCacheAtom ) [ target ]
37+ } ,
4138 ( get , set , { path, action, nestedIndex } ) => {
4239 const target = nestedIndex === undefined
4340 ? path . join ( '.' )
4441 : `${ path . join ( '.' ) } [${ nestedIndex } ]nt`
45- const inspectCache = get ( inspectCacheAtom )
46- return set ( inspectCacheAtom , {
42+ const inspectCache = get ( _inspectCacheAtom )
43+ return set ( _inspectCacheAtom , {
4744 ...inspectCache ,
4845 [ target ] : typeof action === 'function'
4946 ? action ( inspectCache [ target ] )
5047 : action
5148 } )
5249 }
53- )
50+ ) , deepEqual )
51+
5452export const setHoverAtom = atom (
5553 ( get ) => get ( hoverPathAtom ) ,
5654 ( _get , set , { path, nestedIndex } ) => {
0 commit comments