Skip to content

🎥 Make videos programmatically with React

Fix Studio timeline render crash from circular import

Jonny Burger9498d3ef1bf7
diff --git a/packages/studio/src/components/Timeline/Padder.tsx b/packages/studio/src/components/Timeline/Padder.tsx
index c1eafa392e..98732cdaed 100644
--- a/packages/studio/src/components/Timeline/Padder.tsx
+++ b/packages/studio/src/components/Timeline/Padder.tsx
@@ -1,12 +1,12 @@
import React, {useMemo} from 'react';
-import {INDENT} from './TimelineListItem';
+import {TIMELINE_INDENT} from './timeline-indent';
export const Padder: React.FC<{
readonly depth: number;
}> = ({depth}) => {
const style = useMemo(
(): React.CSSProperties => ({
- width: INDENT * depth,
+ width: TIMELINE_INDENT * depth,
flexShrink: 0,
}),
[depth],
diff --git a/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx b/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
index c249a4a74f..6569740360 100644
--- a/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
+++ b/packages/studio/src/components/Timeline/TimelineExpandedRow.tsx
@@ -11,11 +11,11 @@ import {
} from '../../helpers/timeline-layout';
import type {GetIsExpanded} from '../ExpandedTracksProvider';
import {Padder} from './Padder';
+import {TIMELINE_INDENT} from './timeline-indent';
import {TimelineEffectFieldRow} from './TimelineEffectFieldRow';
import {TimelineEffectGroupRow} from './TimelineEffectGroupRow';
import {TimelineExpandArrowButton} from './TimelineExpandArrowButton';
import {TimelineFieldRow} from './TimelineFieldRow';
-import {INDENT} from './TimelineListItem';
const groupRowBase: React.CSSProperties = {
height: TREE_GROUP_ROW_HEIGHT,
@@ -55,18 +55,13 @@ export const TimelineExpandedRow: React.FC<{
nodePath,
schema,
}) => {
- const paddingLeft = EXPANDED_SECTION_PADDING_LEFT + depth * INDENT;
+ const paddingLeft = EXPANDED_SECTION_PADDING_LEFT + depth * TIMELINE_INDENT;
const groupStyle = useMemo(
(): React.CSSProperties => ({...groupRowBase, paddingLeft}),
[paddingLeft],
);
- const effectGroupStyle = useMemo(
- (): React.CSSProperties => ({...groupRowBase, paddingLeft: 5}),
- [],
- );
-
const labelOnlyStyle = useMemo(
(): React.CSSProperties => ({
...labelOnlyRowBase,
@@ -87,8 +82,7 @@ export const TimelineExpandedRow: React.FC<{
nodePath={nodePath}
validatedLocation={validatedLocation}
nestedDepth={nestedDepth}
- depth={depth}
- style={effectGroupStyle}
+ style={groupStyle}
getIsExpanded={getIsExpanded}
toggleTrack={toggleTrack}
/>
diff --git a/packages/studio/src/components/Timeline/TimelineListItem.tsx b/packages/studio/src/components/Timeline/TimelineListItem.tsx
index bcdbc1ac75..e79d6c0f2d 100644
--- a/packages/studio/src/components/Timeline/TimelineListItem.tsx
+++ b/packages/studio/src/components/Timeline/TimelineListItem.tsx
@@ -26,9 +26,7 @@ import {
import {TimelineExpandedSection} from './TimelineExpandedSection';
import {TimelineLayerEye, TimelineLayerEyeSpacer} from './TimelineLayerEye';
import {TimelineStack} from './TimelineStack';
-import {useResolveStackAndReactToChange} from './use-resolved-stack-react-to-change';
-
-export const INDENT = 10;
+import {useResolvedStack} from './use-resolved-stack';
export const TimelineListItem: React.FC<{
readonly sequence: TSequence;
@@ -44,7 +42,7 @@ export const TimelineListItem: React.FC<{
const {codeValues} = useContext(Internals.VisualModeCodeValuesContext);
const {setCodeValues} = useContext(Internals.VisualModeSettersContext);
- const originalLocation = useResolveStackAndReactToChange(sequence.getStack);
+ const originalLocation = useResolvedStack(sequence.stack ?? null);
const validatedLocation = useMemo(() => {
if (
diff --git a/packages/studio/src/components/Timeline/timeline-indent.ts b/packages/studio/src/components/Timeline/timeline-indent.ts
new file mode 100644
index 0000000000..b56cce0833
--- /dev/null
+++ b/packages/studio/src/components/Timeline/timeline-indent.ts
@@ -0,0 +1 @@
+export const TIMELINE_INDENT = 10;