Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions frontend/src/features/dashboard/hooks/useVisualizationData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const EMPTY_FILTERS: FilterType[] = []

export const VISUALIZATION_DATA_QUERY_KEYS = {
all: ['visualization-data'] as const,
forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string) =>
[...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey] as const,
forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string, specKey: string) =>
[...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey, specKey] as const,
}

export interface VisualizationData {
Expand Down Expand Up @@ -63,7 +63,16 @@ export function useVisualizationData(

return useQuery<VisualizationData>({
queryKey: visualization
? VISUALIZATION_DATA_QUERY_KEYS.forViz(visualization.id, fromISO, toISO, filtersKey)
? VISUALIZATION_DATA_QUERY_KEYS.forViz(
visualization.id,
fromISO,
toISO,
filtersKey,
// The saved spec decides what the backend queries. Without it in the
// key, editing a widget leaves the old data cached and staleTime
// keeps serving it after returning to the dashboard.
visualization.spec,
)
: [...VISUALIZATION_DATA_QUERY_KEYS.all, 'noop'],
queryFn: async () => {
if (!spec) return { rows: [], total: 0 }
Expand Down
Loading