Skip to content

Commit

Permalink
fix: same source id delete (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelmala authored Nov 13, 2024
1 parent d574c64 commit 07dba8a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
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

0 comments on commit 07dba8a

Please sign in to comment.