From 6bd5b60b1ef7ae0acd7436ed9dd7ade9ecdfe24a Mon Sep 17 00:00:00 2001 From: nick-delirium Date: Thu, 13 Feb 2025 10:59:47 +0100 Subject: [PATCH] ui: check period start/end to prevent useless calculations --- .../Dashboard/components/WidgetChart/WidgetChart.tsx | 4 ++-- .../Dashboard/components/WidgetDateRange/WidgetDateRange.tsx | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx index 0858b41af..809f0977a 100644 --- a/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx +++ b/frontend/app/components/Dashboard/components/WidgetChart/WidgetChart.tsx @@ -197,10 +197,10 @@ function WidgetChart(props: Props) { if (!inView || !props.isPreview) return; loadComparisonData(); }, [ - dashboardStore.comparisonPeriods[_metric.metricId], - _metric.metricId, inView, props.isPreview, + dashboardStore.comparisonPeriods[_metric.metricId], + _metric.metricId, drillDownPeriod, period, depsString, diff --git a/frontend/app/components/Dashboard/components/WidgetDateRange/WidgetDateRange.tsx b/frontend/app/components/Dashboard/components/WidgetDateRange/WidgetDateRange.tsx index 40f688f32..b8f5158cd 100644 --- a/frontend/app/components/Dashboard/components/WidgetDateRange/WidgetDateRange.tsx +++ b/frontend/app/components/Dashboard/components/WidgetDateRange/WidgetDateRange.tsx @@ -36,6 +36,11 @@ function WidgetDateRange({ }; const onChangeComparison = (period: any) => { + if (compPeriod) { + if (compPeriod.start === period.start && compPeriod.end === period.end) { + return; + } + } dashboardStore.setComparisonPeriod(period, metricStore.instance.metricId); }