fix: use oRPC query keys for sandbox file download and invalidation

Replaced plain array query key in useSandboxFileDownloadUrl with
oRPC-generated queryKey for type safety and consistency. Added
downloadFile cache invalidation to useInvalidateSandboxFiles so
stale download URLs are cleared after workflow/chatflow runs.
This commit is contained in:
yyh
2026-02-04 18:14:02 +08:00
parent 23f98652e1
commit 49de78a20b

View File

@@ -41,7 +41,9 @@ export function useSandboxFileDownloadUrl(
path: string | undefined,
) {
return useQuery({
queryKey: ['sandboxFileDownloadUrl', appId, path],
queryKey: consoleQuery.sandboxFile.downloadFile.queryKey({
input: { params: { appId: appId! }, body: { path: path! } },
}),
queryFn: () => consoleClient.sandboxFile.downloadFile({
params: { appId: appId! },
body: { path: path! },
@@ -56,6 +58,9 @@ export function useInvalidateSandboxFiles() {
queryClient.invalidateQueries({
queryKey: consoleQuery.sandboxFile.listFiles.key(),
})
queryClient.invalidateQueries({
queryKey: consoleQuery.sandboxFile.downloadFile.key(),
})
}, [queryClient])
}