Skip to content

Commit

Permalink
fix: bug sourceId not setting correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelmala committed Nov 7, 2024
1 parent 700aa86 commit 4c4d1f3
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,10 @@ 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
16 changes: 14 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 @@ -73,6 +73,7 @@ export function ConfigureAlignmentLatencyModal({
const [showRestartStreamModal, setShowRestartStreamModal] =
useState<boolean>(false);
const [inputErrors, setInputErrors] = useState<Record<string, boolean>>({});
const [getIngestSourceId] = useIngestSourceId();

const t = useTranslate();
const getIngestStreams = useIngestStreams();
Expand All @@ -99,6 +100,18 @@ export function ConfigureAlignmentLatencyModal({
}
}, [pipelinesAreSelected, latencies, alignments]);

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

fetchSourceId();
}, [source]);

useEffect(() => {
const fetchStreams = async () => {
try {
Expand Down Expand Up @@ -132,7 +145,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
5 changes: 4 additions & 1 deletion src/components/sourceCard/SourceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ export default function SourceCard({
const { locked } = useContext(GlobalContext);

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

const updateText = (event: ChangeEvent<HTMLInputElement>) => {
setSourceLabel(event.currentTarget.value);
Expand Down

0 comments on commit 4c4d1f3

Please sign in to comment.