refactor(web): split TimelineContext into data, view, and display contexts
Reduces unnecessary re-renders by separating the monolithic 20+ property context into TimelineDataContext, TimelineViewContext, and TimelineDisplayContext. Panel components now subscribe only to the slices they need. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,8 @@ import { HEADER_DAY_HEIGHT, HEADER_MONTH_HEIGHT, LABEL_WIDTH } from "./timelineC
|
||||
import { formatDateShort } from "~/lib/format.js";
|
||||
import {
|
||||
TimelineProvider,
|
||||
useTimelineContext,
|
||||
useTimelineData,
|
||||
useTimelineView,
|
||||
type TimelineAssignmentEntry,
|
||||
} from "./TimelineContext.js";
|
||||
import { TimelineResourcePanel } from "./TimelineResourcePanel.js";
|
||||
@@ -339,17 +340,22 @@ function TimelineViewContent({
|
||||
undo: () => Promise<void>;
|
||||
redo: () => Promise<void>;
|
||||
}) {
|
||||
const ctx = useTimelineContext();
|
||||
const {
|
||||
resources,
|
||||
projectGroups,
|
||||
allocsByResource,
|
||||
openDemandsByProject,
|
||||
visibleAssignments,
|
||||
visibleDemands,
|
||||
isLoading,
|
||||
isInitialLoading,
|
||||
isEntriesError,
|
||||
totalAllocCount,
|
||||
} = useTimelineData();
|
||||
const {
|
||||
viewStart,
|
||||
viewEnd,
|
||||
viewDays,
|
||||
visibleAssignments,
|
||||
visibleDemands,
|
||||
setViewStart,
|
||||
setViewDays,
|
||||
filters,
|
||||
@@ -359,11 +365,7 @@ function TimelineViewContent({
|
||||
viewMode,
|
||||
setViewMode,
|
||||
today,
|
||||
isLoading,
|
||||
isInitialLoading,
|
||||
isEntriesError,
|
||||
totalAllocCount,
|
||||
} = ctx;
|
||||
} = useTimelineView();
|
||||
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const canvasRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
Reference in New Issue
Block a user