1
- import React , { useState } from 'react'
1
+ import React , { useEffect , useState } from 'react'
2
2
import cx from 'classnames'
3
3
import { VscEdit } from 'react-icons/vsc'
4
4
import { isUndefined , toNumber } from 'lodash'
@@ -14,8 +14,8 @@ import {
14
14
import { ContextStoreProvider , Database , DatabaseOverview , checkConnectToDatabase , deleteDatabases } from 'uiSrc/store'
15
15
import { Chevron , DatabaseIcon , Tooltip } from 'uiSrc/ui'
16
16
import { PopoverDelete } from 'uiSrc/components'
17
- import { POPOVER_WINDOW_BORDER_WIDTH , VscodeMessageAction } from 'uiSrc/constants'
18
- import { vscodeApi } from 'uiSrc/services'
17
+ import { POPOVER_WINDOW_BORDER_WIDTH , StorageItem , VscodeMessageAction } from 'uiSrc/constants'
18
+ import { sessionStorageService , vscodeApi } from 'uiSrc/services'
19
19
import { Maybe } from 'uiSrc/interfaces'
20
20
21
21
import { LogicalDatabaseWrapper } from '../logical-database-wrapper'
@@ -34,9 +34,20 @@ export const DatabaseWrapper = React.memo(({ database }: Props) => {
34
34
const [ showTree , setShowTree ] = useState < boolean > ( false )
35
35
const [ totalKeysPerDb , setTotalKeysPerDb ] = useState < Maybe < Record < string , number > > > ( undefined )
36
36
37
+ useEffect ( ( ) => {
38
+ const showTreeInit = ! ! sessionStorageService . get ( `${ StorageItem . openTreeDatabase + id } ` )
39
+
40
+ if ( showTreeInit ) {
41
+ checkConnectToDatabase ( id , connectToInstance )
42
+ }
43
+ } , [ ] )
44
+
37
45
const handleCheckConnectToDatabase = ( { id, provider, modules } : Database ) => {
46
+ const newShowTree = ! showTree
47
+ sessionStorageService . set ( `${ StorageItem . openTreeDatabase + id } ` , newShowTree )
48
+
38
49
if ( showTree ) {
39
- setShowTree ( false )
50
+ setShowTree ( newShowTree )
40
51
return
41
52
}
42
53
const modulesSummary = getRedisModulesSummary ( modules )
0 commit comments