Skip to content

Commit

Permalink
fix: correct source type drag and drop (#96)
Browse files Browse the repository at this point in the history
* fix: correct source type drag and drop

* fix: test fail
  • Loading branch information
Saelmala authored Nov 13, 2024
1 parent 1f1fb3b commit d574c64
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/components/sourceCards/SourceCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function SourceCards({
) => Promise<void>;
}) {
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 => {
Expand All @@ -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);
Expand All @@ -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}
Expand Down

0 comments on commit d574c64

Please sign in to comment.