mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 12:05:53 +00:00
fix: use list descendants isntead of v0
This commit is contained in:
@@ -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.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user