mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
fix: ensure caching in file explorers
This commit is contained in:
@@ -46,7 +46,7 @@ export const DirectoryBrowser = ({ onSelectPath, selectedPath }: Props) => {
|
|||||||
setLoadingFolders((prev) => new Set(prev).add(folderPath));
|
setLoadingFolders((prev) => new Set(prev).add(folderPath));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await queryClient.fetchQuery(
|
const result = await queryClient.ensureQueryData(
|
||||||
browseFilesystemOptions({
|
browseFilesystemOptions({
|
||||||
query: { path: folderPath },
|
query: { path: folderPath },
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ export const VolumeFileBrowser = ({
|
|||||||
setLoadingFolders((prev) => new Set(prev).add(folderPath));
|
setLoadingFolders((prev) => new Set(prev).add(folderPath));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await queryClient.fetchQuery(
|
const result = await queryClient.ensureQueryData(
|
||||||
listFilesOptions({
|
listFilesOptions({
|
||||||
path: { name: volumeName },
|
path: { name: volumeName },
|
||||||
query: { path: folderPath },
|
query: { path: folderPath },
|
||||||
@@ -101,7 +101,7 @@ export const VolumeFileBrowser = ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[volumeName, fetchedFolders, queryClient.fetchQuery],
|
[volumeName, fetchedFolders, queryClient.ensureQueryData],
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleFolderHover = useCallback(
|
const handleFolderHover = useCallback(
|
||||||
|
|||||||
@@ -104,7 +104,7 @@ export const SnapshotFileBrowser = (props: Props) => {
|
|||||||
try {
|
try {
|
||||||
const fullPath = addBasePath(folderPath);
|
const fullPath = addBasePath(folderPath);
|
||||||
|
|
||||||
const result = await queryClient.fetchQuery(
|
const result = await queryClient.ensureQueryData(
|
||||||
listSnapshotFilesOptions({
|
listSnapshotFilesOptions({
|
||||||
path: { name: repositoryName, snapshotId: snapshot.short_id },
|
path: { name: repositoryName, snapshotId: snapshot.short_id },
|
||||||
query: { path: fullPath },
|
query: { path: fullPath },
|
||||||
@@ -145,12 +145,12 @@ export const SnapshotFileBrowser = (props: Props) => {
|
|||||||
if (!fetchedFolders.has(folderPath) && !loadingFolders.has(folderPath)) {
|
if (!fetchedFolders.has(folderPath) && !loadingFolders.has(folderPath)) {
|
||||||
const fullPath = addBasePath(folderPath);
|
const fullPath = addBasePath(folderPath);
|
||||||
|
|
||||||
queryClient.prefetchQuery(
|
queryClient.prefetchQuery({
|
||||||
listSnapshotFilesOptions({
|
...listSnapshotFilesOptions({
|
||||||
path: { name: repositoryName, snapshotId: snapshot.short_id },
|
path: { name: repositoryName, snapshotId: snapshot.short_id },
|
||||||
query: { path: fullPath },
|
query: { path: fullPath },
|
||||||
}),
|
}),
|
||||||
);
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[repositoryName, snapshot, fetchedFolders, loadingFolders, queryClient, addBasePath],
|
[repositoryName, snapshot, fetchedFolders, loadingFolders, queryClient, addBasePath],
|
||||||
|
|||||||
@@ -73,8 +73,6 @@ export const repositoriesController = new Hono()
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// c.header("Cache-Control", "public, max-age=10, stale-while-revalidate=60");
|
|
||||||
|
|
||||||
return c.json<ListSnapshotsDto>(snapshots, 200);
|
return c.json<ListSnapshotsDto>(snapshots, 200);
|
||||||
})
|
})
|
||||||
.get("/:name/snapshots/:snapshotId", getSnapshotDetailsDto, async (c) => {
|
.get("/:name/snapshots/:snapshotId", getSnapshotDetailsDto, async (c) => {
|
||||||
@@ -108,7 +106,7 @@ export const repositoriesController = new Hono()
|
|||||||
|
|
||||||
const result = await repositoriesService.listSnapshotFiles(name, snapshotId, path);
|
const result = await repositoriesService.listSnapshotFiles(name, snapshotId, path);
|
||||||
|
|
||||||
// c.header("Cache-Control", "max-age=300, stale-while-revalidate=600");
|
c.header("Cache-Control", "max-age=300, stale-while-revalidate=600");
|
||||||
|
|
||||||
return c.json<ListSnapshotFilesDto>(result, 200);
|
return c.json<ListSnapshotFilesDto>(result, 200);
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ export const volumeController = new Hono()
|
|||||||
path: result.path,
|
path: result.path,
|
||||||
};
|
};
|
||||||
|
|
||||||
// c.header("Cache-Control", "public, max-age=10, stale-while-revalidate=60");
|
c.header("Cache-Control", "public, max-age=10, stale-while-revalidate=60");
|
||||||
|
|
||||||
return c.json<ListFilesDto>(response, 200);
|
return c.json<ListFilesDto>(response, 200);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user