GeezerVison is showing github.com — fix[frontend](dashboards): added visualizations update after edition · utmstack/UTMStack@04f6de1
File treeExpand file treeCollapse file tree Open diff view settings frontend/src/features/dashboard/hooks
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: frontend/src/features/dashboard/hooks/useVisualizationData.ts +12-3Lines changed: 12 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -15,8 +15,8 @@ const EMPTY_FILTERS: FilterType[] = [] | 15 | 15 |
| 16 | 16 | export const VISUALIZATION_DATA_QUERY_KEYS = { | 17 | 17 | all: ['visualization-data'] as const, | 18 | | - forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string) => | 19 | | - [...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey] as const, | | 18 | + forViz: (vizId: string, fromISO: string, toISO: string, filtersKey: string, specKey: string) => | | 19 | + [...VISUALIZATION_DATA_QUERY_KEYS.all, vizId, fromISO, toISO, filtersKey, specKey] as const, | 20 | 20 | } | 21 | 21 |
| 22 | 22 | export interface VisualizationData { | @@ -63,7 +63,16 @@ export function useVisualizationData( | 63 | 63 |
| 64 | 64 | return useQuery<VisualizationData>({ | 65 | 65 | queryKey: visualization | 66 | | - ? VISUALIZATION_DATA_QUERY_KEYS.forViz(visualization.id, fromISO, toISO, filtersKey) | | 66 | + ? VISUALIZATION_DATA_QUERY_KEYS.forViz( | | 67 | + visualization.id, | | 68 | + fromISO, | | 69 | + toISO, | | 70 | + filtersKey, | | 71 | + // The saved spec decides what the backend queries. Without it in the | | 72 | + // key, editing a widget leaves the old data cached and staleTime | | 73 | + // keeps serving it after returning to the dashboard. | | 74 | + visualization.spec, | | 75 | + ) | 67 | 76 | : [...VISUALIZATION_DATA_QUERY_KEYS.all, 'noop'], | 68 | 77 | queryFn: async () => { | 69 | 78 | if (!spec) return { rows: [], total: 0 } | |
|