@@ -69,13 +69,16 @@ const App = () => {
6969 window . location . hash = `#${ params . toString ( ) } ` ;
7070 } , [ itemSize ] ) ;
7171
72- const keyCounter = useRef ( 0 ) ;
72+ const keyCounter = useRef (
73+ Number . parseInt ( localStorage . getItem ( "keyCounter" ) || "0" ) || 0 ,
74+ ) ;
7375 const [ contentKey , saveContentKey ] = useState < string > ( ( ) =>
74- deterministicHash ( `initial- seed-${ keyCounter . current } ` ) ,
76+ deterministicHash ( `seed-${ keyCounter . current } ` ) ,
7577 ) ;
7678
7779 const encryptAndStore = useCallback ( async ( ) => {
7880 const key = deterministicHash ( `seed-${ keyCounter . current } ` ) ;
81+ localStorage . setItem ( "keyCounter" , String ( keyCounter . current ) ) ;
7982 keyCounter . current += 1 ;
8083 saveContentKey ( key ) ;
8184
@@ -127,6 +130,7 @@ const App = () => {
127130 const clear = useCallback ( async ( ) => {
128131 const start = performance . now ( ) ;
129132 await cache . clear ( ) ;
133+ localStorage . removeItem ( "keyCounter" ) ;
130134 const end = performance . now ( ) ;
131135 setClearTime ( end - start ) ;
132136 } , [ ] ) ;
@@ -161,6 +165,7 @@ const App = () => {
161165 data-testid = "reset-cacheKey"
162166 onClick = { ( ) => {
163167 localStorage . removeItem ( "cacheKey" ) ;
168+ localStorage . removeItem ( "keyCounter" ) ;
164169 window . location . reload ( ) ;
165170 } }
166171 >
@@ -185,6 +190,7 @@ const App = () => {
185190 data-testid = "reset-cacheBuster"
186191 onClick = { ( ) => {
187192 localStorage . removeItem ( "cacheBuster" ) ;
193+ localStorage . removeItem ( "keyCounter" ) ;
188194 window . location . reload ( ) ;
189195 } }
190196 >
0 commit comments