Skip to content

Commit

Permalink
fix: only update multiview for low delay
Browse files Browse the repository at this point in the history
  • Loading branch information
Saelmala committed Nov 12, 2024
1 parent a70aa2b commit 573168c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { NextRequest, NextResponse } from 'next/server';
import { isAuthenticated } from '../../../../../../../../api/manager/auth';
import { deleteHtmlFromPipeline } from '../../../../../../../../api/ateliereLive/pipelines/renderingengine/renderingengine';
import { MultiviewSettings } from '../../../../../../../../interfaces/multiview';
import { updateMultiviewForPipeline } from '../../../../../../../../api/ateliereLive/pipelines/multiviews/multiviews';
import { DeleteRenderingEngineSourceStep } from '../../../../../../../../interfaces/Source';
import { Result } from '../../../../../../../../interfaces/result';
import { Log } from '../../../../../../../../api/logger';
import { isAuthenticated } from '../../../../../../../../../api/manager/auth';
import { deleteHtmlFromPipeline } from '../../../../../../../../../api/ateliereLive/pipelines/renderingengine/renderingengine';
import { MultiviewSettings } from '../../../../../../../../../interfaces/multiview';
import { updateMultiviewForPipeline } from '../../../../../../../../../api/ateliereLive/pipelines/multiviews/multiviews';
import { DeleteRenderingEngineSourceStep } from '../../../../../../../../../interfaces/Source';
import { Result } from '../../../../../../../../../interfaces/result';
import { Log } from '../../../../../../../../../api/logger';

type Params = {
id: string;
input_slot: number;
ld_pipeline_id: string;
};

export async function DELETE(
Expand Down Expand Up @@ -79,13 +80,15 @@ export async function DELETE(
if (!singleMultiview.multiview_id) {
throw `The provided multiview settings did not contain any multiview id`;
}
return updateMultiviewForPipeline(
params.id,
singleMultiview.multiview_id,
singleMultiview.layout.views
).catch((e) => {
throw `Error when updating multiview: ${e.message}`;
});
if (params.id === params.ld_pipeline_id) {
return updateMultiviewForPipeline(
params.id,
singleMultiview.multiview_id,
singleMultiview.layout.views
).catch((e) => {
throw `Error when updating multiview: ${e.message}`;
});
}
});

await Promise.all(multiviewUpdates);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { NextRequest, NextResponse } from 'next/server';
import { isAuthenticated } from '../../../../../../../../api/manager/auth';
import { deleteMediaFromPipeline } from '../../../../../../../../api/ateliereLive/pipelines/renderingengine/renderingengine';
import { MultiviewSettings } from '../../../../../../../../interfaces/multiview';
import { updateMultiviewForPipeline } from '../../../../../../../../api/ateliereLive/pipelines/multiviews/multiviews';
import { DeleteRenderingEngineSourceStep } from '../../../../../../../../interfaces/Source';
import { Result } from '../../../../../../../../interfaces/result';
import { Log } from '../../../../../../../../api/logger';
import { isAuthenticated } from '../../../../../../../../../api/manager/auth';
import { deleteMediaFromPipeline } from '../../../../../../../../../api/ateliereLive/pipelines/renderingengine/renderingengine';
import { MultiviewSettings } from '../../../../../../../../../interfaces/multiview';
import { updateMultiviewForPipeline } from '../../../../../../../../../api/ateliereLive/pipelines/multiviews/multiviews';
import { DeleteRenderingEngineSourceStep } from '../../../../../../../../../interfaces/Source';
import { Result } from '../../../../../../../../../interfaces/result';
import { Log } from '../../../../../../../../../api/logger';

type Params = {
id: string;
input_slot: number;
ld_pipeline_id: string;
};

export async function DELETE(
Expand Down Expand Up @@ -63,13 +64,15 @@ export async function DELETE(
if (!singleMultiview.multiview_id) {
throw `The provided multiview settings did not contain any multiview id`;
}
return updateMultiviewForPipeline(
params.id,
singleMultiview.multiview_id,
singleMultiview.layout.views
).catch((e) => {
throw `Error when updating multiview: ${e.message}`;
});
if (params.id === params.ld_pipeline_id) {
return updateMultiviewForPipeline(
params.id,
singleMultiview.multiview_id,
singleMultiview.layout.views
).catch((e) => {
throw `Error when updating multiview: ${e.message}`;
});
}
});

await Promise.all(multiviewUpdates);
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/renderingEngine/useDeleteHtmlSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ export function useDeleteHtmlSource(): CallbackHook<
(v) => v.input_slot === inputSlot
);

const ldPipelineId =
production.production_settings.pipelines[0].pipeline_id;

if (!multiviewsToUpdate || multiviewsToUpdate.length === 0) {
return fetch(
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/html/${inputSlot}`,
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/html/${inputSlot}/${ldPipelineId}`,
{
method: 'DELETE',
headers: [['x-api-key', `Bearer ${API_SECRET_KEY}`]]
Expand Down Expand Up @@ -98,7 +101,7 @@ export function useDeleteHtmlSource(): CallbackHook<
);

return fetch(
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/html/${inputSlot}`,
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/html/${inputSlot}/${ldPipelineId}`,
{
method: 'DELETE',
headers: [['x-api-key', `Bearer ${API_SECRET_KEY}`]],
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/renderingEngine/useDeleteMediaSource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ export function useDeleteMediaSource(): CallbackHook<
(v) => v.input_slot === inputSlot
);

const ldPipelineId =
production.production_settings.pipelines[0].pipeline_id;

if (!multiviewsToUpdate || multiviewsToUpdate.length === 0) {
return fetch(
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/media/${inputSlot}`,
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/media/${inputSlot}/${ldPipelineId}`,
{
method: 'DELETE',
headers: [['x-api-key', `Bearer ${API_SECRET_KEY}`]]
Expand Down Expand Up @@ -98,7 +101,7 @@ export function useDeleteMediaSource(): CallbackHook<
);

return fetch(
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/media/${inputSlot}`,
`/api/manager/pipelines/${pipelineUuid}/rendering-engine/media/${inputSlot}/${ldPipelineId}`,
{
method: 'DELETE',
headers: [['x-api-key', `Bearer ${API_SECRET_KEY}`]],
Expand Down

0 comments on commit 573168c

Please sign in to comment.