Revert homepage

This commit is contained in:
Andras Schmelczer 2026-05-16 20:25:53 +01:00
parent 48c13fbcdd
commit 47d89f6fad
9 changed files with 343 additions and 289 deletions

View file

@ -448,16 +448,26 @@ export function useMapData({
]);
// Use drag data only when it matches the current view feature and request key.
// The first render of a new drag must not reuse the previous drag's preview range.
const dragJustStarted =
Boolean(activeFeature) &&
(previousDragStateRef.current.activeFeature !== activeFeature ||
previousDragStateRef.current.filterStateKey !== filterStateKey);
const hasMatchingDragData =
!dragJustStarted &&
Boolean(activeFeature && viewFeature && activeDragRequest) &&
dragFeatureRef.current === viewFeature &&
dragDataKey === activeDragRequest?.requestKey;
const hasCurrentRangeData = activeFeature
? hasMatchingDragData
: loadedDataKey === dataRequestKey;
const data = (hasMatchingDragData ? dragHexData : null) ?? rawData;
const effectivePostcodeData = (hasMatchingDragData ? dragPostcodeData : null) ?? postcodeData;
// Compute p5/p95 from the data currently being drawn. During slider drags
// this uses the drag-preview data so the colour scale resets to that preview.
const dataRange = useMemo((): [number, number] | null => {
if (!hasCurrentRangeData) return null;
if (!dataViewFeature) return null;
const isTravelTime = dataViewFeature.startsWith('tt_');
@ -499,7 +509,15 @@ export function useMapData({
percentile(vals, COLOR_RANGE_LOW_PERCENTILE),
percentile(vals, COLOR_RANGE_HIGH_PERCENTILE),
];
}, [dataViewFeature, data, effectivePostcodeData, usePostcodeView, features, bounds]);
}, [
bounds,
data,
dataViewFeature,
effectivePostcodeData,
features,
hasCurrentRangeData,
usePostcodeView,
]);
// Live color range for the legend and hex coloring.
const liveColorRange = useMemo((): [number, number] | null => {
@ -516,19 +534,11 @@ export function useMapData({
return [0, meta.values.length - 1];
}
if (dataRange) return dataRange;
if (activeFeature && !hasMatchingDragData) return null;
if (activeFeature) return null;
if (loadedDataKey !== dataRequestKey) return null;
if (meta.min != null && meta.max != null) return [meta.min, meta.max];
return null;
}, [
activeFeature,
dataRequestKey,
dataRange,
dataViewFeature,
features,
hasMatchingDragData,
loadedDataKey,
]);
}, [activeFeature, dataRequestKey, dataRange, dataViewFeature, features, loadedDataKey]);
const isEyePreviewingPinnedFeature =
!activeFeature && dataViewFeature != null && dataViewFeature === pinnedDataViewFeature;