Skip to content

Commit 14c5489

Browse files
committed
#RIVS-305 - Do not collapse the list of keys when going to another extension
1 parent de8c107 commit 14c5489

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/webviews/src/modules/keys-tree/components/database-wrapper/DatabaseWrapper.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState } from 'react'
1+
import React, { useEffect, useState } from 'react'
22
import cx from 'classnames'
33
import { VscEdit } from 'react-icons/vsc'
44
import { isUndefined, toNumber } from 'lodash'
@@ -14,8 +14,8 @@ import {
1414
import { ContextStoreProvider, Database, DatabaseOverview, checkConnectToDatabase, deleteDatabases } from 'uiSrc/store'
1515
import { Chevron, DatabaseIcon, Tooltip } from 'uiSrc/ui'
1616
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'
1919
import { Maybe } from 'uiSrc/interfaces'
2020

2121
import { LogicalDatabaseWrapper } from '../logical-database-wrapper'
@@ -34,9 +34,20 @@ export const DatabaseWrapper = React.memo(({ database }: Props) => {
3434
const [showTree, setShowTree] = useState<boolean>(false)
3535
const [totalKeysPerDb, setTotalKeysPerDb] = useState<Maybe<Record<string, number>>>(undefined)
3636

37+
useEffect(() => {
38+
const showTreeInit = !!sessionStorageService.get(`${StorageItem.openTreeDatabase + id}`)
39+
40+
if (showTreeInit) {
41+
checkConnectToDatabase(id, connectToInstance)
42+
}
43+
}, [])
44+
3745
const handleCheckConnectToDatabase = ({ id, provider, modules }: Database) => {
46+
const newShowTree = !showTree
47+
sessionStorageService.set(`${StorageItem.openTreeDatabase + id}`, newShowTree)
48+
3849
if (showTree) {
39-
setShowTree(false)
50+
setShowTree(newShowTree)
4051
return
4152
}
4253
const modulesSummary = getRedisModulesSummary(modules)

0 commit comments

Comments
 (0)