From b858bd3cad81da41e63b9f8e807e41421ca4aa34 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 8 May 2024 21:03:08 -0400
Subject: lots of api cleanup and cycle removal

---
 src/client/views/nodes/RecordingBox/RecordingBox.tsx | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

(limited to 'src/client/views/nodes/RecordingBox/RecordingBox.tsx')

diff --git a/src/client/views/nodes/RecordingBox/RecordingBox.tsx b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
index e46e40bfe..07381c7d0 100644
--- a/src/client/views/nodes/RecordingBox/RecordingBox.tsx
+++ b/src/client/views/nodes/RecordingBox/RecordingBox.tsx
@@ -50,9 +50,9 @@ export class RecordingBox extends ViewBoxBaseComponent<FieldViewProps>() {
         this.result = info;
         this.dataDoc.type = DocumentType.VID;
 
-        this.dataDoc.layout = VideoBox.LayoutString(this.fieldKey);
+        this.dataDoc[this.fieldKey + '_recorded'] = this.dataDoc.layout; // save the recording layout to allow re-recording later
+        this.dataDoc.layout = VideoBox.LayoutString(this.fieldKey); // then convert the recording box to a video
         this.dataDoc[this._props.fieldKey] = new VideoField(this.result.accessPaths.client);
-        this.dataDoc[this.fieldKey + '_recorded'] = true;
         // stringify the presentation and store it
         if (presentation?.movements) {
             const presCopy = { ...presentation };
@@ -143,18 +143,13 @@ export class RecordingBox extends ViewBoxBaseComponent<FieldViewProps>() {
 
     public static resumeWorkspaceReplaying(doc: Doc) {
         const docView = DocumentView.getDocumentView(doc);
-        if (docView?.ComponentView instanceof VideoBox) {
-            docView.ComponentView.Play();
-        }
+        docView?.ComponentView?.Play?.();
         Doc.UserDoc().workspaceReplayingState = mediaState.Playing;
     }
 
     public static pauseWorkspaceReplaying(doc: Doc) {
         const docView = DocumentView.getDocumentView(doc);
-        const videoBox = docView?.ComponentView as VideoBox;
-        if (videoBox) {
-            videoBox.Pause();
-        }
+        docView?.ComponentView?.Pause?.();
         Doc.UserDoc().workspaceReplayingState = mediaState.Paused;
     }
 
-- 
cgit v1.2.3-70-g09d2

