Skip to content

Commit

Permalink
SOF-1979 Add 'invalidity' field to Segment
Browse files Browse the repository at this point in the history
  • Loading branch information
LindvedKrvang committed May 14, 2024
1 parent 6be3dcb commit 7f9fe5b
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/tv2-common/getSegment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ export interface GetSegmentShowstyleOptions<ShowStyleConfig extends TV2ShowStyle
) => BlueprintResultPart | Promise<BlueprintResultPart>
}

interface Segment<T> extends IBlueprintSegment<T> {
invalidity?: SegmentInvalidity
}

interface SegmentInvalidity {
reason: string
}

interface SegmentMetadata {
miniShelfVideoClipFile?: string
}
Expand All @@ -97,7 +105,7 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>

const segmentPayload = ingestSegment.payload as INewsPayload | undefined
const iNewsStory = segmentPayload?.iNewsStory
const segment: IBlueprintSegment<SegmentMetadata> = {
const segment: Segment<SegmentMetadata> = {
name: ingestSegment.name || '',
metaData: {},
showShelf: false,
Expand Down Expand Up @@ -385,8 +393,23 @@ export async function getSegmentBase<ShowStyleConfig extends TV2ShowStyleConfig>
}
})

segment.invalidity = getSegmentInvalidity(segment, blueprintParts)

return {
segment,
parts: blueprintParts
}
}

function getSegmentInvalidity(
segment: Segment<SegmentMetadata>,
parts: BlueprintResultPart[]
): SegmentInvalidity | undefined {
const doesSegmentHaveMiniShelf: boolean = !!segment.metaData?.miniShelfVideoClipFile
if (doesSegmentHaveMiniShelf && parts.length > 0) {
return {
reason: 'MiniShelf Segments are not allowed to also have Parts.'
}
}
return undefined
}

0 comments on commit 7f9fe5b

Please sign in to comment.