minimap: fix debounced zoom cleanup

This commit is contained in:
Danielv123 committed 2026-02-09 19:19:48 +01:00
1 parent 35575a93a3
commit 5ff7d7ee42
1 file changed
+8 -8
+8 -8
View File
@@ -1846,34 +1846,34 @@ export default function CanvasMinimapPage({
return () => { }; return () => { };
}, [selectedSurface, selectedForce, isTimelapseMode, activeViewKey, isReady, dataSource]); }, [selectedSurface, selectedForce, isTimelapseMode, activeViewKey, isReady, dataSource]);
// Load existing chart tags when instance/surface/force selection changes // Load existing chart tags when instance/surface/force selection changes
useEffect(() => { useEffect(() => {
if (isReady) { if (isReady) {
loadExistingChartTags(); loadExistingChartTags();
} else { } else {
// Clear chart tags if no valid selection // Clear chart tags if no valid selection
setRawChartTags([]); setRawChartTags([]);
setPlayerPositions(new Map()); setPlayerPositions(new Map());
} }
}, [selectedSurface, selectedForce, activeViewKey, isReady, dataSource]); }, [selectedSurface, selectedForce, activeViewKey, isReady, dataSource]);
// Snap current zoom level to nearest pixel-perfect level on mount // Snap current zoom level to nearest pixel-perfect level on mount
useEffect(() => { useEffect(() => {
updateViewState({ updateViewState({
zoomLevel: getClosestZoomLevel(viewStateRef.current.zoomLevel), zoomLevel: getClosestZoomLevel(viewStateRef.current.zoomLevel),
}); });
// Cleanup throttled zoom update on unmount // Cleanup debounced zoom update on unmount
return () => { return () => {
if (throttledZoomUpdate.current) { if (debouncedZoomUpdate.current) {
clearTimeout(throttledZoomUpdate.current); clearTimeout(debouncedZoomUpdate.current);
} }
}; };
}, []); }, []);
// Get visible chart tags based on current state // Get visible chart tags based on current state
const getVisibleChartTags = useCallback(() => { const getVisibleChartTags = useCallback(() => {
// Use the same ref state that the render function uses for consistency // Use the same ref state that the render function uses for consistency
const currentState = currentStateRef.current; const currentState = currentStateRef.current;
if (!currentState.isReady || !currentState.showChartTags) { if (!currentState.isReady || !currentState.showChartTags) {