From 44f8581a41b595b64b6cb3c5aec408079f55f43e Mon Sep 17 00:00:00 2001 From: tiny-craft <137850705+tiny-craft@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:25:35 +0800 Subject: [PATCH] fix: incorrect keys count display of database after delete the only remaining key. #47 --- frontend/src/stores/connections.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/frontend/src/stores/connections.js b/frontend/src/stores/connections.js index a731a13..52b72d3 100644 --- a/frontend/src/stores/connections.js +++ b/frontend/src/stores/connections.js @@ -532,11 +532,10 @@ const useConnectionStore = defineStore('connections', { selDB.opened = true if (isEmpty(keys)) { selDB.children = [] - return + } else { + // append db node to current connection's children + this._addKeyNodes(connName, db, keys) } - - // append db node to current connection's children - this._addKeyNodes(connName, db, keys) this._tidyNode(connName, db) }, @@ -874,7 +873,7 @@ const useConnectionStore = defineStore('connections', { /** * sort all node item's children and calculate keys count - * @param node + * @param {DatabaseItem} node * @param {boolean} skipSort skip sorting children * @returns {boolean} return whether key count changed * @private @@ -891,7 +890,12 @@ const useConnectionStore = defineStore('connections', { count += elem.keys } } else { - count += 1 + if (node.type === ConnectionType.RedisValue) { + count += 1 + } else { + // no children in db node or layer node, set count to 0 + count = 0 + } } if (node.keys !== count) { node.keys = count