better metric table chart updates

This commit is contained in:
Nate Kelley 2025-04-21 08:24:04 -06:00
parent 4d071843df
commit 0870b52f04
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 5 additions and 13 deletions

View File

@ -1,7 +1,6 @@
import React, { useCallback } from 'react';
import type { BusterTableChartConfig } from './interfaces';
import { formatLabel } from '@/lib/columnFormatter';
import isEqual from 'lodash/isEqual';
import {
type IBusterMetricChartConfig,
type BusterChartPropsBase,
@ -11,9 +10,8 @@ import { useMemoizedFn } from '@/hooks';
import { AppDataGrid } from '@/components/ui/table/AppDataGrid';
import './TableChart.css';
import { cn } from '@/lib/classMerge';
import isEmpty from 'lodash/isEmpty';
import { useUpdateMetricChart } from '@/context/Metrics';
import { useUpdateMetric } from '@/api/buster_rest/metrics';
import { useOriginalMetricStore } from '@/context/Metrics/useOriginalMetricStore';
export interface BusterTableChartProps extends BusterTableChartConfig, BusterChartPropsBase {}
@ -37,7 +35,10 @@ const BusterTableChartBase: React.FC<BusterTableChartProps> = ({
if (readOnly) return;
onUpdateMetricChartConfig({ chartConfig: config });
if (tableColumnWidths === null && !!config.tableColumnWidths) {
if (
(tableColumnWidths === null || isEmpty(tableColumnWidths)) &&
!isEmpty(config.tableColumnWidths)
) {
onInitializeTableColumnWidths(config.tableColumnWidths);
}
});

View File

@ -31,9 +31,6 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin
saveToServer: true,
updateVersion: !chatId
});
const { mutateAsync: saveMetricToServerWithoutSideEffects } = useSaveMetric({
updateOnSave: true
});
const getMetricMemoized = useGetMetricMemoized();
@ -145,12 +142,6 @@ export const useUpdateMetricChart = (props?: { metricId?: string; chatId?: strin
...originalMetric,
chart_config: newChartConfig
});
saveMetricToServerWithoutSideEffects({
id: metricId,
chart_config: newChartConfig,
update_version: false
});
}
}
);