From b1b3e794927e88efe5dbd548423cc3b8096ba107 Mon Sep 17 00:00:00 2001 From: malmen237 Date: Wed, 4 Sep 2024 11:54:42 +0200 Subject: [PATCH] fix: changed to a some-check instead of a map --- src/app/production/[id]/page.tsx | 34 +++++++------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/app/production/[id]/page.tsx b/src/app/production/[id]/page.tsx index 2db7a40..309a4ce 100644 --- a/src/app/production/[id]/page.tsx +++ b/src/app/production/[id]/page.tsx @@ -258,7 +258,6 @@ export default function ProductionConfiguration({ params }: PageProps) { putProduction(updatedSetup._id.toString(), updatedSetup); const pipeline = updatedSetup.production_settings.pipelines[0]; - // ! What is the consequence of this? Cannot see the effect -> pipeline.multiview?.map((singleMultiview) => { if ( pipeline.pipeline_id && @@ -273,15 +272,6 @@ export default function ProductionConfiguration({ params }: PageProps) { ); } }); - - // if ( - // pipeline.pipeline_id && - // pipeline.multiview && - // pipeline.multiview.multiview_id - // ) { - // updateMultiviewViews(pipeline.pipeline_id, updatedSetup, source); - // } - // ! <- }; const updateConfigName = (nameChange: string) => { @@ -437,7 +427,6 @@ export default function ProductionConfiguration({ params }: PageProps) { productionSetup && productionSetup.isActive && selectedSource && - // ! What is the consequence of this? Cannot see the effect -> (Array.isArray( productionSetup?.production_settings.pipelines[0].multiview ) @@ -445,8 +434,6 @@ export default function ProductionConfiguration({ params }: PageProps) { (singleMultiview) => singleMultiview?.layout?.views ) : false) - // productionSetup.production_settings.pipelines[0].multiview?.layout.views - // ! <- ) { const firstEmptySlot = getFirstEmptySlot(); const result = await createStream( @@ -498,23 +485,16 @@ export default function ProductionConfiguration({ params }: PageProps) { selectedSourceRef && selectedSourceRef.stream_uuids ) { - const multiview = + const multiviews = productionSetup.production_settings.pipelines[0].multiview; - if (!multiview) return; + if (!multiviews || multiviews.length === 0) return; - // ! What is the consequence of this? Cannot see the effect -> - // const viewToUpdate = multiview?.layout.views.find( - // (v) => v.input_slot === selectedSourceRef.input_slot - // ); - const viewToUpdate = multiview - ? multiview.map((item) => { - item.layout.views.find( - (v) => v.input_slot === selectedSourceRef.input_slot - ); - }) - : false; - // ! <- + const viewToUpdate = multiviews.some((multiview) => + multiview.layout.views.find( + (v) => v.input_slot === selectedSourceRef.input_slot + ) + ); if (!viewToUpdate) { if (!productionSetup.production_settings.pipelines[0].pipeline_id)