Skip to content

Commit

Permalink
fix: new key to a non-current database incorrectly refresh the tree v…
Browse files Browse the repository at this point in the history
  • Loading branch information
tiny-craft committed May 21, 2024
1 parent f536b0f commit a2b0fc1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 10 additions & 3 deletions frontend/src/components/dialogs/NewKeyDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ const onAdd = async () => {
value = defaultValue[type]
}
// await browserStore.reloadKey({server, db, key: trim(key)})
const { success, msg, nodeKey } = await browserStore.setKey({
const {
success,
msg,
nodeKey = '',
} = await browserStore.setKey({
server,
db,
key: trim(key),
Expand All @@ -165,8 +169,11 @@ const onAdd = async () => {
if (success) {
// select current key
await nextTick()
tabStore.setSelectedKeys(server, nodeKey)
browserStore.reloadKey({ server, db, key })
const selectedDB = browserStore.getSelectedDB(server)
if (selectedDB === db) {
tabStore.setSelectedKeys(server, nodeKey)
browserStore.reloadKey({ server, db, key })
}
} else if (!isEmpty(msg)) {
$message.error(msg)
}
Expand Down
13 changes: 7 additions & 6 deletions frontend/src/stores/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -832,19 +832,20 @@ const useBrowserStore = defineStore('browser', {
if (success) {
/** @type RedisServerState **/
const serverInst = this.servers[server]
if (serverInst != null) {
if (serverInst != null && serverInst.db === db) {
// const { value } = data
// update tree view data
const { newKey = 0 } = serverInst.addKeyNodes([key], true)
if (newKey > 0) {
serverInst.tidyNode(key)
serverInst.updateDBKeyCount(db, newKey)
}
}
const { value: updatedValue } = data
if (updatedValue != null) {
const tab = useTabStore()
tab.updateValue({ server, db, key, value: updatedValue })

const { value: updatedValue } = data
if (updatedValue != null) {
const tab = useTabStore()
tab.updateValue({ server, db, key, value: updatedValue })
}
}
// this.loadKeySummary({ server, db, key })
return {
Expand Down

0 comments on commit a2b0fc1

Please sign in to comment.