From d574c646391af3a737aaafe3aafc00d7ec1a4fe5 Mon Sep 17 00:00:00 2001 From: Sandra Larsson Date: Wed, 13 Nov 2024 14:48:04 +0100 Subject: [PATCH] fix: correct source type drag and drop (#96) * fix: correct source type drag and drop * fix: test fail --- src/components/sourceCards/SourceCards.tsx | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/components/sourceCards/SourceCards.tsx b/src/components/sourceCards/SourceCards.tsx index d2314204..922b5c2d 100644 --- a/src/components/sourceCards/SourceCards.tsx +++ b/src/components/sourceCards/SourceCards.tsx @@ -36,6 +36,7 @@ export default function SourceCards({ ) => Promise; }) { const [items, moveItem] = useDragableItems(productionSetup.sources); + const itemsToAdd: SourceReference[] = []; const [selectingText, setSelectingText] = useState(false); if (!items) return null; const isISource = (source: SourceReference | ISource): source is ISource => { @@ -53,7 +54,24 @@ export default function SourceCards({ } const productionSources = productionSetup.sources; - for (let i = 0; i < items[items.length - 1].input_slot; i++) { + for (const item of items) { + if (isISource(item)) { + const itemId = + typeof item._id === 'string' ? item._id : item._id.toString(); + const itemAsRef: SourceReference = { + _id: itemId, + type: 'ingest_source', + label: item.label, + stream_uuids: item.stream_uuids, + input_slot: item.input_slot + }; + itemsToAdd.push(itemAsRef); + } else { + itemsToAdd.push(item); + } + } + + for (let i = 0; i < itemsToAdd[itemsToAdd.length - 1].input_slot; i++) { tempItems.every((source) => { const id = source._id ? source._id : ''; const isSource = isISource(source); @@ -66,7 +84,7 @@ export default function SourceCards({ id={id} onMoveItem={moveItem} previousOrder={productionSetup.sources} - currentOrder={items as SourceReference[]} + currentOrder={itemsToAdd} productionSetup={productionSetup} updateProduction={updateProduction} selectingText={selectingText}