Skip to content

Commit

Permalink
Fix/make sure source id is correct (#86)
Browse files Browse the repository at this point in the history
* fix: make sure sourceId is correct for settings

* fix: prettier test fail
  • Loading branch information
Saelmala authored Nov 8, 2024
1 parent 4000c00 commit 2e95afc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ export async function GET(
}

try {
const ingestUuid = await getUuidFromIngestName(params.ingest_name);
const ingestUuid = await getUuidFromIngestName(params.ingest_name, false);
const sourceId = ingestUuid
? await getSourceIdFromSourceName(ingestUuid, params.ingest_source_name)
? await getSourceIdFromSourceName(
ingestUuid,
params.ingest_source_name,
false
)
: 0;
return new NextResponse(JSON.stringify(sourceId), { status: 200 });
} catch (error) {
Expand Down
15 changes: 13 additions & 2 deletions src/components/modal/ConfigureAlignmentLatencyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button } from '../button/Button';
import { Loader } from '../loader/Loader';
import { ISource } from '../../hooks/useDragableItems';
import { useState, useEffect, useRef } from 'react';
import { useIngestStreams } from '../../hooks/ingests';
import { useIngestStreams, useIngestSourceId } from '../../hooks/ingests';
import { useGetProductionSourceAlignmentAndLatency } from '../../hooks/productions';
import {
ResourcesCompactPipelineResponse,
Expand Down Expand Up @@ -77,6 +77,7 @@ export function ConfigureAlignmentLatencyModal({
const getProductionSourceAlignmentAndLatency =
useGetProductionSourceAlignmentAndLatency();
const [pipelines] = GetPipelines();
const [getIngestSourceId] = useIngestSourceId();

useEffect(() => {
setAvailablePipelines(pipelines);
Expand All @@ -97,6 +98,17 @@ export function ConfigureAlignmentLatencyModal({
}
}, [pipelinesAreSelected, latencies, alignments]);

useEffect(() => {
const fetchSourceId = async () => {
const id = await getIngestSourceId(
source.ingest_name,
source.ingest_source_name
);
setSourceId(id);
};
fetchSourceId();
}, [source]);

useEffect(() => {
const fetchStreams = async () => {
try {
Expand Down Expand Up @@ -130,7 +142,6 @@ export function ConfigureAlignmentLatencyModal({
newAlignments[stream.pipeline_uuid] = 0;
newLatencies[stream.pipeline_uuid] = 0;
}
setSourceId(stream.source_id);
}
} else if (availablePipelines) {
for (const pipeline of availablePipelines) {
Expand Down
3 changes: 2 additions & 1 deletion src/components/sourceCard/SourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export default function SourceCard({

const pipelinesAreSelected =
productionSetup?.production_settings.pipelines.some(
(pipeline) => pipeline.pipeline_id === undefined
(pipeline) =>
pipeline.pipeline_id === undefined || pipeline.pipeline_id === ''
) === false;

const updateText = (event: ChangeEvent<HTMLInputElement>) => {
Expand Down

0 comments on commit 2e95afc

Please sign in to comment.