BUR-63 Добавлен abortSignal для прекращения "не успевших" запросов по тегам при сттарте нового запроса диапзона дат

This commit is contained in:
Первов Артем
2026-07-05 05:48:07 +03:00
parent 46cf3da755
commit 095df38e7e
3 changed files with 4 additions and 4 deletions

View File

@@ -3,6 +3,6 @@ import { cloudApiUrl } from '../../shared/config/env';
import type { HistoryRequest, HistoryResponse } from './types';
/** Запрашивает исторический ряд с avg-линией и min/max-диапазоном для графика. */
export function getHistory(params: HistoryRequest): Promise<HistoryResponse> {
return getJson<HistoryResponse>(cloudApiUrl, '/history', params);
export function getHistory(params: HistoryRequest, signal?: AbortSignal): Promise<HistoryResponse> {
return getJson<HistoryResponse>(cloudApiUrl, '/history', params, { signal });
}

View File

@@ -254,7 +254,7 @@ export function ArchiveView({
{selectedTags.length ? (
<HistoryChart
key={`${range.from}:${range.to}:${selectedTags.join(',')}`}
key={`${range.from}:${range.to}:${historyAxis.granulate}`}
edge={edgeId}
from={fromIso}
to={toIso}

View File

@@ -33,7 +33,7 @@ export function useHistoryChartQueries({
const queries = useQueries({
queries: tags.map((tag) => ({
queryKey: ['history', edge, tag, from, to, granulate],
queryFn: () => getHistory({ edge, tag, from, to, granulate }),
queryFn: ({ signal }: { signal: AbortSignal }) => getHistory({ edge, tag, from, to, granulate }, signal),
enabled,
})),
});