From bc6aa7b8e7c9e43901f500d58acb0ebb6450b0a5 Mon Sep 17 00:00:00 2001
From: Michael <michael.foiani@gmail.com>
Date: Wed, 8 Jun 2022 15:38:40 -0400
Subject: got basic ordering to work for the videos that go to the server

---
 src/client/views/nodes/RecordingBox/ProgressBar.tsx | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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

diff --git a/src/client/views/nodes/RecordingBox/ProgressBar.tsx b/src/client/views/nodes/RecordingBox/ProgressBar.tsx
index 3314da355..a91656cbc 100644
--- a/src/client/views/nodes/RecordingBox/ProgressBar.tsx
+++ b/src/client/views/nodes/RecordingBox/ProgressBar.tsx
@@ -9,6 +9,7 @@ import { MediaSegment } from './RecordingView';
 interface ProgressBarProps {
   videos: MediaSegment[],
   setVideos: React.Dispatch<React.SetStateAction<MediaSegment[]>>,
+  orderVideos: boolean,
 }
 
 interface SegmentBox {
@@ -46,7 +47,7 @@ export function ProgressBar(props: ProgressBarProps) {
 
   useEffect(() => {
     const order = props.videos.length
-    if (order) {
+    if (order && !props.orderVideos) {
       const { endTime, startTime } = props.videos.lastElement();
       setOrdered(prevOrdered => {
         return [...prevOrdered, { endTime, startTime , order }];
@@ -59,6 +60,10 @@ export function ProgressBar(props: ProgressBarProps) {
     // }))
   }, [props.videos]);
 
+  useEffect(() => {
+    props.setVideos(vids => ordered.map((seg) => vids[seg.order - 1]));
+  }, [props.orderVideos]);
+
 
 
       // const handleClick = (e: React.MouseEvent) => {
-- 
cgit v1.2.3-70-g09d2

