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: bug with deleting a source if another source with same id present in production #97

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions src/app/production/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,8 @@ export default function ProductionConfiguration({ params }: PageProps) {
const updatedSetup = removeSetupItem(
selectedSourceRef,
productionSetup,
ingestSourceId
ingestSourceId,
ingestSource?.ingest_name
);

if (!updatedSetup) return;
Expand Down Expand Up @@ -1193,7 +1194,8 @@ export default function ProductionConfiguration({ params }: PageProps) {
input_slot: source.input_slot
},
productionSetup,
ingestSourceId
ingestSourceId,
ingestSource?.ingest_name
);
if (!updatedSetup) return;
setProductionSetup(updatedSetup);
Expand Down
9 changes: 6 additions & 3 deletions src/hooks/items/removeSetupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@ import { Production } from '../../interfaces/production';
export function removeSetupItem(
source: SourceReference,
productionSetup: Production,
ingestSourceId?: number
ingestSourceId?: number,
ingestName?: string
): Production | null {
const tempItems = productionSetup.sources.filter(
(tempItem) => tempItem._id !== source._id
);

let updatedPipelines = productionSetup.production_settings.pipelines;

if (ingestSourceId !== undefined) {
if (ingestSourceId !== undefined && ingestName !== undefined) {
updatedPipelines = productionSetup.production_settings.pipelines.map(
(pipeline) => ({
...pipeline,
sources: pipeline.sources
? pipeline.sources.filter(
(pipelineSource) => pipelineSource.source_id !== ingestSourceId
(pipelineSource) =>
pipelineSource.source_id !== ingestSourceId ||
pipelineSource.settings.ingest_name !== ingestName
)
: []
})
Expand Down
Loading