3 Commits

3 changed files with 10 additions and 5 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

@@ -202,7 +202,12 @@ export function ArchiveView({
) : null}
</div>
<div className="archive-chart">
<div
className="archive-chart"
onFocusCapture={() => setSelectorOpen(false)}
onPointerDown={() => setSelectorOpen(false)}
onPointerEnter={() => setSelectorOpen(false)}
>
<div className="toolbar">
<div className="segmented">
{RANGE_PRESETS.map((preset) => (
@@ -249,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,
})),
});