fix: use list descendants isntead of v0

This commit is contained in:
Calum H. (IMB11)
2026-06-26 17:09:23 +01:00
parent af6aec8dec
commit 2e08fe7950
3 changed files with 10 additions and 51 deletions
@@ -41,8 +41,8 @@ export default defineNuxtRouteMiddleware(async (to) => {
if (tab === 'files') {
const path = typeof to.query.path === 'string' ? to.query.path : '/'
await queryClient.ensureQueryData({
queryKey: ['files', serverId, path],
queryFn: () => client.kyros.files_v0.listDirectory(path, 1, 2000),
queryKey: ['files', 'v1', worldId, path],
queryFn: () => client.kyros.files_v1.listDescendants(worldId, path, 1, 200),
staleTime: 30_000,
})
return
@@ -7,18 +7,20 @@ import {
import { useQueryClient } from '@tanstack/vue-query'
const client = injectModrinthClient()
const { server, serverId } = injectModrinthServerContext()
const { server, worldId } = injectModrinthServerContext()
const queryClient = useQueryClient()
const flags = useFeatureFlags()
const route = useNativeRoute()
const initialPath = typeof route.query.path === 'string' ? route.query.path : '/'
try {
await queryClient.ensureQueryData({
queryKey: ['files', serverId, initialPath],
queryFn: () => client.kyros.files_v0.listDirectory(initialPath, 1, 2000),
staleTime: 30_000,
})
if (worldId.value) {
await queryClient.ensureQueryData({
queryKey: ['files', 'v1', worldId.value, initialPath],
queryFn: () => client.kyros.files_v1.listDescendants(worldId.value!, initialPath, 1, 200),
staleTime: 30_000,
})
}
} catch {
// Let mounted layouts' useQuery surface errors; do not fail route setup.
}