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') { if (tab === 'files') {
const path = typeof to.query.path === 'string' ? to.query.path : '/' const path = typeof to.query.path === 'string' ? to.query.path : '/'
await queryClient.ensureQueryData({ await queryClient.ensureQueryData({
queryKey: ['files', serverId, path], queryKey: ['files', 'v1', worldId, path],
queryFn: () => client.kyros.files_v0.listDirectory(path, 1, 2000), queryFn: () => client.kyros.files_v1.listDescendants(worldId, path, 1, 200),
staleTime: 30_000, staleTime: 30_000,
}) })
return return
@@ -7,18 +7,20 @@ import {
import { useQueryClient } from '@tanstack/vue-query' import { useQueryClient } from '@tanstack/vue-query'
const client = injectModrinthClient() const client = injectModrinthClient()
const { server, serverId } = injectModrinthServerContext() const { server, worldId } = injectModrinthServerContext()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const flags = useFeatureFlags() const flags = useFeatureFlags()
const route = useNativeRoute() const route = useNativeRoute()
const initialPath = typeof route.query.path === 'string' ? route.query.path : '/' const initialPath = typeof route.query.path === 'string' ? route.query.path : '/'
try { try {
await queryClient.ensureQueryData({ if (worldId.value) {
queryKey: ['files', serverId, initialPath], await queryClient.ensureQueryData({
queryFn: () => client.kyros.files_v0.listDirectory(initialPath, 1, 2000), queryKey: ['files', 'v1', worldId.value, initialPath],
staleTime: 30_000, queryFn: () => client.kyros.files_v1.listDescendants(worldId.value!, initialPath, 1, 200),
}) staleTime: 30_000,
})
}
} catch { } catch {
// Let mounted layouts' useQuery surface errors; do not fail route setup. // Let mounted layouts' useQuery surface errors; do not fail route setup.
} }
@@ -166,49 +166,6 @@ export class KyrosFilesV0Module extends AbstractModule {
}) })
} }
/**
* Move a file or folder to a new location
*
* @param sourcePath - Current path
* @param destPath - New path
*/
public async moveFileOrFolder(sourcePath: string, destPath: string): Promise<void> {
return this.client.request<void>('/fs/move', {
api: '',
version: 'modrinth/v0',
method: 'POST',
body: { source: sourcePath, destination: destPath },
useNodeAuth: true,
})
}
/**
* Rename a file or folder (convenience wrapper around move)
*
* @param path - Current file/folder path
* @param newName - New name (not full path)
*/
public async renameFileOrFolder(path: string, newName: string): Promise<void> {
const newPath = path.split('/').slice(0, -1).join('/') + '/' + newName
return this.moveFileOrFolder(path, newPath)
}
/**
* Delete a file or folder
*
* @param path - Path to delete
* @param recursive - If true, delete directory contents recursively
*/
public async deleteFileOrFolder(path: string, recursive: boolean): Promise<void> {
return this.client.request<void>('/fs/delete', {
api: '',
version: 'modrinth/v0',
method: 'DELETE',
params: { path, recursive },
useNodeAuth: true,
})
}
/** /**
* Delete a file or folder using explicit filesystem auth credentials. * Delete a file or folder using explicit filesystem auth credentials.
* *