Skip to content

Commit

Permalink
Automerge 'staging' to 'develop'.
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions # Blueprint-Automation authored and GitHub Actions # Blueprint-Automation committed May 16, 2024
2 parents 94eec99 + 1f308ce commit 13ee2d8
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 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,24 @@ 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
const doesSegmentHaveValidParts: boolean = parts.length > 0 && parts.some((part) => part.pieces.length > 0)
if (doesSegmentHaveMiniShelf && doesSegmentHaveValidParts) {
return {
reason: 'MiniShelf Segments are not allowed to also have Parts.'
}
}
return undefined
}

0 comments on commit 13ee2d8

Please sign in to comment.