fix: ensure caching in file explorers

This commit is contained in:
Nicolas Meienberger
2025-11-11 18:01:54 +01:00
parent ff7f6ffad9
commit a1cc89c66e
5 changed files with 9 additions and 11 deletions

View File

@@ -46,7 +46,7 @@ export const DirectoryBrowser = ({ onSelectPath, selectedPath }: Props) => {
setLoadingFolders((prev) => new Set(prev).add(folderPath));
try {
const result = await queryClient.fetchQuery(
const result = await queryClient.ensureQueryData(
browseFilesystemOptions({
query: { path: folderPath },
}),

View File

@@ -72,7 +72,7 @@ export const VolumeFileBrowser = ({
setLoadingFolders((prev) => new Set(prev).add(folderPath));
try {
const result = await queryClient.fetchQuery(
const result = await queryClient.ensureQueryData(
listFilesOptions({
path: { name: volumeName },
query: { path: folderPath },
@@ -101,7 +101,7 @@ export const VolumeFileBrowser = ({
}
}
},
[volumeName, fetchedFolders, queryClient.fetchQuery],
[volumeName, fetchedFolders, queryClient.ensureQueryData],
);
const handleFolderHover = useCallback(

View File

@@ -104,7 +104,7 @@ export const SnapshotFileBrowser = (props: Props) => {
try {
const fullPath = addBasePath(folderPath);
const result = await queryClient.fetchQuery(
const result = await queryClient.ensureQueryData(
listSnapshotFilesOptions({
path: { name: repositoryName, snapshotId: snapshot.short_id },
query: { path: fullPath },
@@ -145,12 +145,12 @@ export const SnapshotFileBrowser = (props: Props) => {
if (!fetchedFolders.has(folderPath) && !loadingFolders.has(folderPath)) {
const fullPath = addBasePath(folderPath);
queryClient.prefetchQuery(
listSnapshotFilesOptions({
queryClient.prefetchQuery({
...listSnapshotFilesOptions({
path: { name: repositoryName, snapshotId: snapshot.short_id },
query: { path: fullPath },
}),
);
});
}
},
[repositoryName, snapshot, fetchedFolders, loadingFolders, queryClient, addBasePath],