Skip to content

Commit 473cfcc

Browse files
committed
fix(kb): use active scope in useWorkspaceFileRecord to share cache with useWorkspaceFiles
1 parent 3865ee7 commit 473cfcc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

apps/sim/hooks/queries/workspace-files.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ export interface StorageInfo {
3535

3636
/**
3737
* Hook to fetch a single workspace file record by ID.
38-
* Uses the full list query so the result is shared from cache when available.
38+
* Uses the same query key as useWorkspaceFiles so the result is served from cache when the list is already loaded.
3939
*/
4040
export function useWorkspaceFileRecord(workspaceId: string, fileId: string) {
4141
return useQuery({
42-
queryKey: workspaceFilesKeys.list(workspaceId, 'all'),
43-
queryFn: ({ signal }) => fetchWorkspaceFiles(workspaceId, 'all', signal),
42+
queryKey: workspaceFilesKeys.list(workspaceId, 'active'),
43+
queryFn: ({ signal }) => fetchWorkspaceFiles(workspaceId, 'active', signal),
4444
enabled: !!workspaceId && !!fileId,
4545
staleTime: 30 * 1000,
4646
select: (files) => files.find((f) => f.id === fileId) ?? null,

0 commit comments

Comments
 (0)