Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-1979 Add 'invalidity' field to Segment #243

Merged
merged 2 commits into from
May 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Loading