From 31d6acefca449d5d4857e0f71372eedb7b89b645 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Thu, 2 Sep 2021 21:46:45 +0200 Subject: [PATCH] Fix the bug with non-existing trackData --- theatre/studio/src/store/stateEditors.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/theatre/studio/src/store/stateEditors.ts b/theatre/studio/src/store/stateEditors.ts index da069e7..28ce658 100644 --- a/theatre/studio/src/store/stateEditors.ts +++ b/theatre/studio/src/store/stateEditors.ts @@ -458,7 +458,7 @@ namespace stateEditors { function _getTrack( p: WithoutSheetInstance & {trackId: string}, ) { - return _ensureTracksOfObject(p).trackData[p.trackId]! + return _ensureTracksOfObject(p).trackData[p.trackId] } /** @@ -474,7 +474,9 @@ namespace stateEditors { }, ) { const position = p.snappingFunction(p.position) - const {keyframes} = _getTrack(p) + const track = _getTrack(p) + if (!track) return + const {keyframes} = track const existingKeyframeIndex = keyframes.findIndex( (kf) => kf.position === position, ) @@ -513,7 +515,9 @@ namespace stateEditors { position: number }, ) { - const {keyframes} = _getTrack(p) + const track = _getTrack(p) + if (!track) return + const {keyframes} = track const index = keyframes.findIndex( (kf) => kf.position === p.position, ) @@ -535,6 +539,7 @@ namespace stateEditors { }, ) { const track = _getTrack(p) + if (!track) return const initialKeyframes = current(track.keyframes) // debugger @@ -560,6 +565,7 @@ namespace stateEditors { }, ) { const track = _getTrack(p) + if (!track) return track.keyframes = track.keyframes.filter( (kf) => p.keyframeIds.indexOf(kf.id) === -1, @@ -574,6 +580,7 @@ namespace stateEditors { }, ) { const track = _getTrack(p) + if (!track) return const initialKeyframes = current(track.keyframes) const sanitizedKeyframes = p.keyframes .filter((kf) => {