@@ -6,7 +6,7 @@ import { Dispatch, SetStateAction, useCallback, useEffect, useMemo, useRef, useS
66import dynamic from "next/dynamic" ;
77import { cn , fetchOptions , formatName , getDefaultQuery , getQueryWithLimit , getSSEGraphResult , Panel , prepareArg , securedFetch , Tab , getMemoryUsage , GraphRef , ConnectionType , ConnectionInfo , UDFEntry , UDFEntryWithCode , getMetaStats , HistoryQuery , GraphData , Label , Relationship , InfoLabel , Query , Data , MemoryValue } from "@/lib/utils" ;
88import { encryptValue , decryptValue , isCryptoAvailable , isEncrypted } from "@/lib/encryption" ;
9- import { getConnectionItem , setConnectionItem , setConnectionPrefix , clearConnectionPrefix , migrateToScopedStorage } from "@/lib/connection-storage" ;
9+ import { getConnectionItem , setConnectionItem , removeConnectionItem , setConnectionPrefix , clearConnectionPrefix , migrateToScopedStorage } from "@/lib/connection-storage" ;
1010import { usePathname , useRouter } from "next/navigation" ;
1111import { useToast } from "@/components/ui/use-toast" ;
1212import { ResizableHandle , ResizablePanel , ResizablePanelGroup } from "@/components/ui/resizable" ;
@@ -69,6 +69,9 @@ function ProvidersWithSession({ children }: { children: React.ReactNode }) {
6969 migrateToScopedStorage ( ) ;
7070 setPrefixReady ( true ) ;
7171 } else {
72+ // Clean up scoped data before clearing the prefix,
73+ // so removeConnectionItem can still resolve the scoped key.
74+ removeConnectionItem ( "savedContent" ) ;
7275 clearConnectionPrefix ( ) ;
7376 setPrefixReady ( false ) ;
7477 }
@@ -134,15 +137,15 @@ function ProvidersWithSession({ children }: { children: React.ReactNode }) {
134137 const [ cypherOnly , setCypherOnly ] = useState < boolean > ( false ) ;
135138 const [ udfList , setUdfList ] = useState < UDFEntry [ ] > ( [ ] ) ;
136139 const [ selectedUdf , setSelectedUdf ] = useState < UDFEntryWithCode > ( ) ;
137- const [ columnWidth , setColumnWidth ] = useState < number > ( 0 ) ;
138- const [ rowHeight , setRowHeight ] = useState < number > ( 0 ) ;
139- const [ newColumnWidth , setNewColumnWidth ] = useState < number > ( 0 ) ;
140- const [ newRowHeight , setNewRowHeight ] = useState < number > ( 0 ) ;
141- const [ newRowHeightExpandMultiple , setNewRowHeightExpandMultiple ] = useState < number > ( 0 ) ;
142- const [ rowHeightExpandMultiple , setRowHeightExpandMultiple ] = useState < number > ( 0 ) ;
140+ const [ columnWidth , setColumnWidth ] = useState < number > ( 25 ) ;
141+ const [ rowHeight , setRowHeight ] = useState < number > ( 40 ) ;
142+ const [ newColumnWidth , setNewColumnWidth ] = useState < number > ( 25 ) ;
143+ const [ newRowHeight , setNewRowHeight ] = useState < number > ( 40 ) ;
144+ const [ newRowHeightExpandMultiple , setNewRowHeightExpandMultiple ] = useState < number > ( 3 ) ;
145+ const [ rowHeightExpandMultiple , setRowHeightExpandMultiple ] = useState < number > ( 3 ) ;
143146 const [ showUDF , setShowUDF ] = useState < boolean > ( true ) ;
144- const [ maxItemsForSearch , setMaxItemsForSearch ] = useState < number > ( 0 ) ;
145- const [ newMaxItemsForSearch , setNewMaxItemsForSearch ] = useState < number > ( 0 ) ;
147+ const [ maxItemsForSearch , setMaxItemsForSearch ] = useState < number > ( 20 ) ;
148+ const [ newMaxItemsForSearch , setNewMaxItemsForSearch ] = useState < number > ( 20 ) ;
146149
147150 const replayTutorial = useCallback ( ( ) => {
148151 router . push ( "/graph" ) ;
@@ -478,13 +481,15 @@ function ProvidersWithSession({ children }: { children: React.ReactNode }) {
478481 fetchCount ( n ) ;
479482 setLastLimit ( limit ) ;
480483
481- if ( ! tutorialOpen ) {
484+ if ( ! tutorialOpen && prefixReady ) {
482485 setConnectionItem ( "savedContent" , JSON . stringify ( { graphName : n , query : q } ) ) ;
483486 }
484487
485488 const newQueries = handelGetNewQueries ( newQuery ) ;
486489
487- setConnectionItem ( "query history" , JSON . stringify ( newQueries ) ) ;
490+ if ( prefixReady ) {
491+ setConnectionItem ( "query history" , JSON . stringify ( newQueries ) ) ;
492+ }
488493
489494 setHistoryQuery ( prev => ( {
490495 ...prev ,
@@ -503,7 +508,7 @@ function ProvidersWithSession({ children }: { children: React.ReactNode }) {
503508 setIsQueryLoading ( false ) ;
504509 }
505510 // eslint-disable-next-line react-hooks/exhaustive-deps
506- } , [ graphName , limit , timeout , fetchInfo , fetchCount , handleCooldown , handelGetNewQueries , showMemoryUsage , captionsKeys , showPropertyKeyPrefix , tutorialOpen ] ) ;
511+ } , [ graphName , limit , timeout , fetchInfo , fetchCount , handleCooldown , handelGetNewQueries , showMemoryUsage , captionsKeys , showPropertyKeyPrefix , tutorialOpen , prefixReady ] ) ;
507512
508513 const graphContext = useMemo ( ( ) => ( {
509514 graph,
@@ -649,7 +654,8 @@ function ProvidersWithSession({ children }: { children: React.ReactNode }) {
649654 setColumnWidth ( parseInt ( localStorage . getItem ( "columnWidth" ) || "25" , 10 ) ) ;
650655 setRowHeight ( parseInt ( localStorage . getItem ( "rowHeight" ) || "40" , 10 ) ) ;
651656 setRowHeightExpandMultiple ( parseInt ( localStorage . getItem ( "rowHeightExpandMultiple" ) || "3" , 10 ) ) ;
652- setMaxItemsForSearch ( parseInt ( localStorage . getItem ( "maxItemsForSearch" ) || "20" , 10 ) ) ;
657+ const parsedMaxItems = parseInt ( localStorage . getItem ( "maxItemsForSearch" ) || "20" , 10 ) ;
658+ setMaxItemsForSearch ( Number . isFinite ( parsedMaxItems ) ? Math . min ( Math . max ( parsedMaxItems , 10 ) , 50 ) : 20 ) ;
653659 // Decrypt secret key if encrypted, or migrate plain text keys to encrypted format
654660 const storedSecretKey = localStorage . getItem ( "secretKey" ) || "" ;
655661 if ( storedSecretKey ) {
0 commit comments