-
Notifications
You must be signed in to change notification settings - Fork 54
feat: allow part to be queued from onTake #1497
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
base: release53
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,7 +198,13 @@ export async function performTakeToNextedPart( | |
| const showStyle = await pShowStyle | ||
| const blueprint = await context.getShowStyleBlueprint(showStyle._id) | ||
|
|
||
| const { isTakeAborted } = await executeOnTakeCallback(context, playoutModel, showStyle, blueprint, currentRundown) | ||
| const { isTakeAborted, queuePart } = await executeOnTakeCallback( | ||
| context, | ||
| playoutModel, | ||
| showStyle, | ||
| blueprint, | ||
| currentRundown | ||
| ) | ||
|
|
||
| if (isTakeAborted) { | ||
| await updateTimeline(context, playoutModel) | ||
|
|
@@ -264,8 +270,12 @@ export async function performTakeToNextedPart( | |
| resetPreviousSegmentIfLooping(context, playoutModel) | ||
| } | ||
|
|
||
| // Once everything is synced, we can choose the next part | ||
| await setNextPart(context, playoutModel, nextPart, false) | ||
| if (queuePart) { | ||
| await queuePart() | ||
| } else { | ||
| // Once everything is synced, we can choose the next part | ||
| await setNextPart(context, playoutModel, nextPart, false) | ||
| } | ||
|
|
||
| // If the Hold is PENDING, make it active | ||
| if (playoutModel.playlist.holdState === RundownHoldState.PENDING) { | ||
|
|
@@ -289,17 +299,19 @@ async function executeOnTakeCallback( | |
| showStyle: ReadonlyObjectDeep<ProcessedShowStyleCompound>, | ||
| blueprint: ReadonlyObjectDeep<WrappedShowStyleBlueprint>, | ||
| currentRundown: PlayoutRundownModel | ||
| ): Promise<{ isTakeAborted: boolean }> { | ||
| ): Promise<{ isTakeAborted: boolean; queuePart: (() => Promise<void>) | undefined }> { | ||
| const NOTIFICATION_CATEGORY = 'onTake' | ||
|
|
||
| let isTakeAborted = false | ||
| let queuePart: (() => Promise<void>) | undefined = undefined | ||
| if (blueprint.blueprint.onTake) { | ||
| const rundownId = currentRundown.rundown._id | ||
| const partInstanceId = playoutModel.playlist.nextPartInfo?.partInstanceId | ||
| if (!partInstanceId) throw new Error('Cannot call blueprint onTake when there is no next partInstance!') | ||
|
|
||
| // Clear any existing notifications for this partInstance. This will clear any from the previous take | ||
| playoutModel.clearAllNotifications(NOTIFICATION_CATEGORY) | ||
| const actionService = new PartAndPieceInstanceActionService(context, playoutModel, showStyle, currentRundown) | ||
|
|
||
| const watchedPackagesHelper = WatchedPackagesHelper.empty(context) | ||
| const onSetAsNextContext = new OnTakeContext( | ||
|
|
@@ -313,7 +325,7 @@ async function executeOnTakeCallback( | |
| playoutModel, | ||
| showStyle, | ||
| watchedPackagesHelper, | ||
| new PartAndPieceInstanceActionService(context, playoutModel, showStyle, currentRundown) | ||
| actionService | ||
| ) | ||
| try { | ||
| const blueprintPersistentState = new PersistentPlayoutStateStore( | ||
|
|
@@ -323,6 +335,12 @@ async function executeOnTakeCallback( | |
| await blueprint.blueprint.onTake(onSetAsNextContext, blueprintPersistentState) | ||
| await applyOnTakeSideEffects(context, playoutModel, onSetAsNextContext) | ||
| isTakeAborted = onSetAsNextContext.isTakeAborted | ||
| if (onSetAsNextContext.partToQueue) { | ||
| const partToQueue = onSetAsNextContext.partToQueue | ||
| queuePart = async () => { | ||
| await actionService.queuePart(partToQueue.rawPart, partToQueue.rawPieces) | ||
|
||
| } | ||
| } | ||
|
|
||
| if (blueprintPersistentState.hasChanges) { | ||
| playoutModel.setBlueprintPersistentState(blueprintPersistentState.getAll()) | ||
|
|
@@ -354,7 +372,7 @@ async function executeOnTakeCallback( | |
| }) | ||
| } | ||
| } | ||
| return { isTakeAborted } | ||
| return { isTakeAborted, queuePart } | ||
| } | ||
|
|
||
| async function applyOnTakeSideEffects(context: JobContext, playoutModel: PlayoutModel, onTakeContext: OnTakeContext) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition of nextPart would be good to move into this else block, so that it is only run when needed and make sure it doesnt get used elsewhere accidentally