Skip to content

🎥 Make videos programmatically with React

`@remotion/studio`: Fix undo for mixed static and keyframed canvas edits

Jonny Burger17219e9628b6
diff --git a/packages/studio/src/components/SelectedOutlineCanvasRotation.tsx b/packages/studio/src/components/SelectedOutlineCanvasRotation.tsx
index 4dfa42ac48..451041b339 100644
--- a/packages/studio/src/components/SelectedOutlineCanvasRotation.tsx
+++ b/packages/studio/src/components/SelectedOutlineCanvasRotation.tsx
@@ -34,7 +34,6 @@ import {
type SelectedOutlineTarget,
} from './selected-outline-types';
import {svgPointToClientPoint} from './svg-point-to-client-point';
-import {callAddKeyframes} from './Timeline/call-add-keyframe';
import {commitPendingInspectorFields} from './Timeline/focus-inspector-field';
import {getCurrentFrame} from './Timeline/imperative-state';
import {saveSequenceProps} from './Timeline/save-sequence-prop';
@@ -260,25 +259,15 @@ export const SelectedOutlineCanvasRotation: React.FC<{
change.type === 'keyframed',
);
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- addedKeyframes: null,
- movedKeyframes: null,
- setPropStatuses,
- clientId: rotationDrag.clientId,
- undoLabel: 'Rotate sequence',
- redoLabel: 'Rotate sequence back',
- })
- : Promise.resolve(),
- callAddKeyframes({
- sequenceKeyframes: keyframedChanges,
- effectKeyframes: [],
- setPropStatuses,
- clientId: rotationDrag.clientId,
- }),
- ])
+ saveSequenceProps({
+ changes: staticChanges,
+ addedKeyframes: keyframedChanges,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId: rotationDrag.clientId,
+ undoLabel: 'Rotate sequence',
+ redoLabel: 'Rotate sequence back',
+ })
.catch((error) => {
showNotification(
`Could not save sequence props: ${
diff --git a/packages/studio/src/components/SelectedOutlineKeyboardControls.tsx b/packages/studio/src/components/SelectedOutlineKeyboardControls.tsx
index 79203ff6c6..fbc2c5fe58 100644
--- a/packages/studio/src/components/SelectedOutlineKeyboardControls.tsx
+++ b/packages/studio/src/components/SelectedOutlineKeyboardControls.tsx
@@ -14,7 +14,6 @@ import type {
SelectedOutlineDragTarget,
SelectedOutlineKeyboardNudgeSession,
} from './selected-outline-types';
-import {callAddKeyframes} from './Timeline/call-add-keyframe';
import {getCurrentDuration, getCurrentFps} from './Timeline/imperative-state';
import {saveSequenceProps} from './Timeline/save-sequence-prop';
import {ensureFrameIsInViewport} from './Timeline/timeline-scroll-logic';
@@ -78,29 +77,19 @@ export const SelectedOutlineKeyboardControls: React.FC<{
change.type === 'keyframed',
);
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- addedKeyframes: null,
- movedKeyframes: null,
- setPropStatuses,
- clientId,
- undoLabel:
- changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
- redoLabel:
- changes.length > 1
- ? 'Move selected sequences back'
- : 'Move sequence back',
- })
- : Promise.resolve(),
- callAddKeyframes({
- sequenceKeyframes: keyframedChanges,
- effectKeyframes: [],
- setPropStatuses,
- clientId,
- }),
- ])
+ saveSequenceProps({
+ changes: staticChanges,
+ addedKeyframes: keyframedChanges,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId,
+ undoLabel:
+ changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
+ redoLabel:
+ changes.length > 1
+ ? 'Move selected sequences back'
+ : 'Move sequence back',
+ })
.catch((err) => {
showNotification(
`Could not save sequence props: ${
diff --git a/packages/studio/src/components/SelectedOutlinePolygon.tsx b/packages/studio/src/components/SelectedOutlinePolygon.tsx
index 19096758a4..0fd90d43b6 100644
--- a/packages/studio/src/components/SelectedOutlinePolygon.tsx
+++ b/packages/studio/src/components/SelectedOutlinePolygon.tsx
@@ -39,7 +39,6 @@ import type {
SelectedOutlineLayoutTarget,
SelectedOutlineTarget,
} from './selected-outline-types';
-import {callAddKeyframes} from './Timeline/call-add-keyframe';
import {commitPendingInspectorFields} from './Timeline/focus-inspector-field';
import {getCurrentFrame} from './Timeline/imperative-state';
import {saveSequenceProps} from './Timeline/save-sequence-prop';
@@ -274,31 +273,19 @@ const SelectedOutlinePolygonUnmemoized: React.FC<{
change.type === 'keyframed',
);
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- addedKeyframes: null,
- movedKeyframes: null,
- setPropStatuses,
- clientId,
- undoLabel:
- changes.length > 1
- ? 'Move selected sequences'
- : 'Move sequence',
- redoLabel:
- changes.length > 1
- ? 'Move selected sequences back'
- : 'Move sequence back',
- })
- : Promise.resolve(),
- callAddKeyframes({
- sequenceKeyframes: keyframedChanges,
- effectKeyframes: [],
- setPropStatuses,
- clientId,
- }),
- ])
+ saveSequenceProps({
+ changes: staticChanges,
+ addedKeyframes: keyframedChanges,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId,
+ undoLabel:
+ changes.length > 1 ? 'Move selected sequences' : 'Move sequence',
+ redoLabel:
+ changes.length > 1
+ ? 'Move selected sequences back'
+ : 'Move sequence back',
+ })
.catch((err) => {
showNotification(
`Could not save sequence props: ${
diff --git a/packages/studio/src/components/SelectedOutlineRotationCornerHandle.tsx b/packages/studio/src/components/SelectedOutlineRotationCornerHandle.tsx
index b1dde7bd99..842783d54c 100644
--- a/packages/studio/src/components/SelectedOutlineRotationCornerHandle.tsx
+++ b/packages/studio/src/components/SelectedOutlineRotationCornerHandle.tsx
@@ -36,7 +36,6 @@ import {
type SelectedOutlineTarget,
} from './selected-outline-types';
import {svgPointToClientPoint} from './svg-point-to-client-point';
-import {callAddKeyframes} from './Timeline/call-add-keyframe';
import {commitPendingInspectorFields} from './Timeline/focus-inspector-field';
import {getCurrentFrame} from './Timeline/imperative-state';
import {saveSequenceProps} from './Timeline/save-sequence-prop';
@@ -266,31 +265,21 @@ export const SelectedOutlineRotationCornerHandle: React.FC<{
change.type === 'keyframed',
);
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- addedKeyframes: null,
- movedKeyframes: null,
- setPropStatuses,
- clientId: rotationDrag.clientId,
- undoLabel:
- changes.length > 1
- ? 'Rotate selected sequences'
- : 'Rotate sequence',
- redoLabel:
- changes.length > 1
- ? 'Rotate selected sequences back'
- : 'Rotate sequence back',
- })
- : Promise.resolve(),
- callAddKeyframes({
- sequenceKeyframes: keyframedChanges,
- effectKeyframes: [],
- setPropStatuses,
- clientId: rotationDrag.clientId,
- }),
- ])
+ saveSequenceProps({
+ changes: staticChanges,
+ addedKeyframes: keyframedChanges,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId: rotationDrag.clientId,
+ undoLabel:
+ changes.length > 1
+ ? 'Rotate selected sequences'
+ : 'Rotate sequence',
+ redoLabel:
+ changes.length > 1
+ ? 'Rotate selected sequences back'
+ : 'Rotate sequence back',
+ })
.catch((err) => {
showNotification(
`Could not save sequence props: ${
diff --git a/packages/studio/src/components/SelectedOutlineScaleEdgeLine.tsx b/packages/studio/src/components/SelectedOutlineScaleEdgeLine.tsx
index 2289c6efdf..85f8420511 100644
--- a/packages/studio/src/components/SelectedOutlineScaleEdgeLine.tsx
+++ b/packages/studio/src/components/SelectedOutlineScaleEdgeLine.tsx
@@ -30,7 +30,6 @@ import {
type SelectedOutlineScaleDragTarget,
type SelectedOutlineTarget,
} from './selected-outline-types';
-import {callAddKeyframes} from './Timeline/call-add-keyframe';
import {commitPendingInspectorFields} from './Timeline/focus-inspector-field';
import {getCurrentFrame} from './Timeline/imperative-state';
import {saveSequenceProps} from './Timeline/save-sequence-prop';
@@ -205,31 +204,19 @@ export const SelectedOutlineScaleEdgeLine: React.FC<{
change.type === 'keyframed',
);
- Promise.all([
- staticChanges.length > 0
- ? saveSequenceProps({
- changes: staticChanges,
- addedKeyframes: null,
- movedKeyframes: null,
- setPropStatuses,
- clientId: scaleDrag.clientId,
- undoLabel:
- changes.length > 1
- ? 'Scale selected sequences'
- : 'Scale sequence',
- redoLabel:
- changes.length > 1
- ? 'Scale selected sequences back'
- : 'Scale sequence back',
- })
- : Promise.resolve(),
- callAddKeyframes({
- sequenceKeyframes: keyframedChanges,
- effectKeyframes: [],
- setPropStatuses,
- clientId: scaleDrag.clientId,
- }),
- ])
+ saveSequenceProps({
+ changes: staticChanges,
+ addedKeyframes: keyframedChanges,
+ movedKeyframes: null,
+ setPropStatuses,
+ clientId: scaleDrag.clientId,
+ undoLabel:
+ changes.length > 1 ? 'Scale selected sequences' : 'Scale sequence',
+ redoLabel:
+ changes.length > 1
+ ? 'Scale selected sequences back'
+ : 'Scale sequence back',
+ })
.catch((err) => {
showNotification(
`Could not save sequence props: ${