Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct source type drag and drop #96

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading