diff --git a/app/[host]/database/[database]/@nav/loading.tsx b/app/[host]/database/[database]/@nav/loading.tsx
index ae451296..86cd9f27 100644
--- a/app/[host]/database/[database]/@nav/loading.tsx
+++ b/app/[host]/database/[database]/@nav/loading.tsx
@@ -1,5 +1,5 @@
import { ListSkeleton } from '@/components/skeleton'
export default function Loading() {
- return
+ return
}
diff --git a/app/[host]/database/[database]/@nav/nav.tsx b/app/[host]/database/[database]/@nav/nav.tsx
index 5c2a3e19..0add9bd8 100644
--- a/app/[host]/database/[database]/@nav/nav.tsx
+++ b/app/[host]/database/[database]/@nav/nav.tsx
@@ -6,6 +6,7 @@ import { ErrorAlert } from '@/components/error-alert'
import { fetchData } from '@/lib/clickhouse'
import { cn } from '@/lib/utils'
+import { cache } from 'react'
import { listDatabases } from '../../queries'
import { DatabaseBreadcrumb } from './breadcrumb'
@@ -21,25 +22,32 @@ interface DatabaseCount {
count: number
}
+export const getListDatabaseCached = cache(async () => {
+ return fetchData({
+ query: listDatabases,
+ clickhouse_settings: {
+ use_query_cache: 1,
+ query_cache_system_table_handling: 'save',
+ query_cache_ttl: 300,
+ },
+ })
+})
+
+export const preload = async (host: number) => {
+ void (await getListDatabaseCached())
+}
+
export async function Nav({ host, database, collapsible }: Props) {
+ preload(host)
let databases: DatabaseCount[] = []
try {
- // List database names and number of tables
- const data = (await fetchData({
- query: listDatabases,
- clickhouse_settings: {
- use_query_cache: 1,
- query_cache_system_table_handling: 'save',
- query_cache_ttl: 300,
- },
- })) satisfies { data: DatabaseCount[] }
-
- databases = data.data
+ const data = await getListDatabaseCached()
+ databases = data.data as DatabaseCount[]
} catch (e: any) {
return (
@@ -104,12 +112,19 @@ function Sidebar({
'hover:bg-accent hover:text-accent-foreground',
'focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring',
'disabled:pointer-events-none disabled:opacity-50',
- db.name === current && 'bg-secondary'
+ db.name === current && 'bg-secondary font-bold'
)}
>
- {db.name}
+
+ {db.name}
+
{db.count}