refactor(web): extract timeline drag cleanup

This commit is contained in:
2026-04-01 11:12:20 +02:00
parent 922394c56a
commit b14be80e32
5 changed files with 199 additions and 14 deletions
+17 -14
View File
@@ -20,6 +20,7 @@ import {
} from "./timelineAllocationMultiDrag.js";
import { resolveAllocationRelease } from "./timelineAllocationRelease.js";
import { createAllocationDragState } from "./timelineAllocationDragState.js";
import { cleanupTimelineDragState } from "./timelineDragCleanup.js";
import { attachDocumentMouseDrag } from "./timelineDocumentDrag.js";
import { buildProjectShiftMutationInput, createProjectDragState } from "./timelineProjectDrag.js";
import {
@@ -1005,20 +1006,22 @@ export function useTimelineDrag({
useEffect(() => {
return () => {
projectDragCleanupRef.current?.();
allocDragCleanupRef.current?.();
multiSelectCleanupRef.current?.();
projectDragCleanupRef.current = null;
allocDragCleanupRef.current = null;
multiSelectCleanupRef.current = null;
clearLivePreview(projectPreviewRef.current);
clearLivePreview(allocPreviewRef.current);
projectPreviewRef.current = null;
allocPreviewRef.current = null;
dragStateRef.current = INITIAL_DRAG_STATE;
allocDragRef.current = INITIAL_ALLOC_DRAG;
rangeStateRef.current = INITIAL_RANGE_STATE;
multiSelectRef.current = INITIAL_MULTI_SELECT;
cleanupTimelineDragState({
projectDragCleanupRef,
allocDragCleanupRef,
multiSelectCleanupRef,
projectPreviewRef,
allocPreviewRef,
dragStateRef,
allocDragRef,
rangeStateRef,
multiSelectRef,
initialDragState: INITIAL_DRAG_STATE,
initialAllocDragState: INITIAL_ALLOC_DRAG,
initialRangeState: INITIAL_RANGE_STATE,
initialMultiSelectState: INITIAL_MULTI_SELECT,
clearPreview: clearLivePreview,
});
};
}, []);