fix(saved-sql): count nested SQL files

This commit is contained in:
t8y2 committed 2026-06-26 00:07:19 +08:00
1 parent 2c23e206ba
commit 3a9cf0336a
3 files changed
+67 -2

No files matched your search

@@ -13,6 +13,7 @@ import { useConnectionStore } from "@/stores/connectionStore";
import { useQueryStore } from "@/stores/queryStore";
import { useSettingsStore } from "@/stores/settingsStore";
import { focusSidebarRenameInput } from "@/lib/sidebarRenameFocus";
import { savedSqlFolderBranchFileCount } from "@/lib/savedSqlFolderCounts";
import type { SavedSqlFile, SavedSqlFolder } from "@/types/database";
const { t } = useI18n();
@@ -342,6 +343,11 @@ function filesInFolder(folderId: string) {
.filter((file) => includeAllFilesForMatchedFolder || fileMatchesQuery(file));
}
function folderFileCount(folderId: string) {
const visibleFolders = savedSqlStore.allFolders.filter((folder) => isConnectionVisible(folder.connectionId));
return savedSqlFolderBranchFileCount(folderId, visibleFolders, filesInFolder);
}
type SqlLibraryRow = { type: "folder"; folder: SavedSqlFolder; depth: number; folderIndex: number } | { type: "file"; file: SavedSqlFile; depth: number };
const visibleFolderRows = computed<SqlLibraryRow[]>(() => {
@@ -1061,7 +1067,7 @@ function showDropInside(targetId: string) {
<FolderClosed class="h-4 w-4 text-amber-500 shrink-0" />
<span class="dbx-sql-library-drag-label min-w-0 flex-1 truncate">
{{ item.item.name }}
<span class="ml-1 text-muted-foreground">({{ filesInFolder(item.item.id).length }})</span>
<span class="ml-1 text-muted-foreground">({{ folderFileCount(item.item.id) }})</span>
</span>
</div>
@@ -1119,7 +1125,7 @@ function showDropInside(targetId: string) {
</template>
<span v-else class="dbx-sql-library-drag-label min-w-0 flex-1 truncate">
{{ row.folder.name }}
<span class="ml-1 text-muted-foreground">({{ filesInFolder(row.folder.id).length }})</span>
<span class="ml-1 text-muted-foreground">({{ folderFileCount(row.folder.id) }})</span>
</span>
</div>