Skip to content

Commit d115751

Browse files
committed
fix(logs): replace initialData with placeholderData to fix stale log details
1 parent 3fa4bb4 commit d115751

File tree

1 file changed

+1
-16
lines changed

1 file changed

+1
-16
lines changed

apps/sim/hooks/queries/logs.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
type QueryClient,
44
useInfiniteQuery,
55
useQuery,
6-
useQueryClient,
76
} from '@tanstack/react-query'
87
import { getEndDateFromTimeRange, getStartDateFromTimeRange } from '@/lib/logs/filters'
98
import { parseQuery, queryToApiParams } from '@/lib/logs/query-parser'
@@ -159,27 +158,13 @@ interface UseLogDetailOptions {
159158
}
160159

161160
export function useLogDetail(logId: string | undefined, options?: UseLogDetailOptions) {
162-
const queryClient = useQueryClient()
163161
return useQuery({
164162
queryKey: logKeys.detail(logId),
165163
queryFn: () => fetchLogDetail(logId as string),
166164
enabled: Boolean(logId) && (options?.enabled ?? true),
167165
refetchInterval: options?.refetchInterval ?? false,
168166
staleTime: 30 * 1000,
169-
initialData: () => {
170-
if (!logId) return undefined
171-
const listQueries = queryClient.getQueriesData<{
172-
pages: { logs: WorkflowLog[] }[]
173-
}>({
174-
queryKey: logKeys.lists(),
175-
})
176-
for (const [, data] of listQueries) {
177-
const match = data?.pages?.flatMap((p) => p.logs).find((l) => l.id === logId)
178-
if (match) return match
179-
}
180-
return undefined
181-
},
182-
initialDataUpdatedAt: 0,
167+
placeholderData: keepPreviousData,
183168
})
184169
}
185170

0 commit comments

Comments
 (0)