Small changes

This commit is contained in:
Andras Schmelczer 2026-03-12 22:11:33 +00:00
parent eae78df3ca
commit 593f380581
7 changed files with 48 additions and 48 deletions

View file

@ -31,7 +31,6 @@ interface UseMapDataOptions {
features: FeatureMeta[];
viewFeature: string | null;
activeFeature: string | null;
dragValue: [number, number] | null;
travelTimeEntries: TravelTimeEntry[];
}
@ -40,7 +39,6 @@ export function useMapData({
features,
viewFeature,
activeFeature,
dragValue,
travelTimeEntries,
}: UseMapDataOptions) {
const [rawData, setRawData] = useState<HexagonData[]>([]);
@ -75,17 +73,15 @@ export function useMapData({
[filters, features]
);
// Build the travel param string from entries with destinations
// Format: mode:slug|mode:slug:best or mode:slug:min:max|mode:slug:best:min:max
// Build the travel param string from entries with destinations.
// timeRange is NOT included — range filtering is handled purely client-side
// (dimming in useDeckLayers) so slider changes never trigger server refetches.
const travelParam = useMemo((): string => {
const segments: string[] = [];
for (const entry of travelTimeEntries) {
if (!entry.slug) continue;
let seg = `${entry.mode}:${entry.slug}`;
if (entry.useBest) seg += ':best';
if (entry.timeRange) {
seg += `:${entry.timeRange[0]}:${entry.timeRange[1]}`;
}
segments.push(seg);
}
return segments.join('|');
@ -259,7 +255,6 @@ export function useMapData({
if (!isTravelTime) {
const meta = features.find((f) => f.name === viewFeature);
if (!meta || meta.type === 'enum') return null;
if (activeFeature && !dragHexData && !dragPostcodeData) return null;
}
const vals: number[] = [];
@ -294,7 +289,7 @@ export function useMapData({
percentile(vals, COLOR_RANGE_LOW_PERCENTILE),
percentile(vals, COLOR_RANGE_HIGH_PERCENTILE),
];
}, [viewFeature, data, dragHexData, dragPostcodeData, effectivePostcodeData, usePostcodeView, features, activeFeature, bounds]);
}, [viewFeature, data, effectivePostcodeData, usePostcodeView, features, bounds]);
// Color range for the legend and hex coloring
const colorRange = useMemo((): [number, number] | null => {
@ -311,10 +306,9 @@ export function useMapData({
return [0, meta.values.length - 1];
}
if (dataRange) return dataRange;
if (activeFeature && dragValue) return dragValue;
if (meta.min != null && meta.max != null) return [meta.min, meta.max];
return null;
}, [viewFeature, features, dataRange, activeFeature, dragValue]);
}, [viewFeature, features, dataRange]);
const handleViewChange = useCallback(
({