fix: incorrect keys count display of database after delete the only remaining key. #47

This commit is contained in:
tiny-craft 2023-10-11 16:25:35 +08:00
parent 76734989d5
commit 44f8581a41
1 changed files with 10 additions and 6 deletions

View File

@ -532,11 +532,10 @@ const useConnectionStore = defineStore('connections', {
selDB.opened = true selDB.opened = true
if (isEmpty(keys)) { if (isEmpty(keys)) {
selDB.children = [] selDB.children = []
return } else {
}
// append db node to current connection's children // append db node to current connection's children
this._addKeyNodes(connName, db, keys) this._addKeyNodes(connName, db, keys)
}
this._tidyNode(connName, db) this._tidyNode(connName, db)
}, },
@ -874,7 +873,7 @@ const useConnectionStore = defineStore('connections', {
/** /**
* sort all node item's children and calculate keys count * sort all node item's children and calculate keys count
* @param node * @param {DatabaseItem} node
* @param {boolean} skipSort skip sorting children * @param {boolean} skipSort skip sorting children
* @returns {boolean} return whether key count changed * @returns {boolean} return whether key count changed
* @private * @private
@ -891,7 +890,12 @@ const useConnectionStore = defineStore('connections', {
count += elem.keys count += elem.keys
} }
} else { } else {
if (node.type === ConnectionType.RedisValue) {
count += 1 count += 1
} else {
// no children in db node or layer node, set count to 0
count = 0
}
} }
if (node.keys !== count) { if (node.keys !== count) {
node.keys = count node.keys = count