From 7fe60eab0a39907575ad05eabd2c1d45f01d0d99 Mon Sep 17 00:00:00 2001
From: Mint de Wit <mint@superfly.tv>
Date: Wed, 25 Sep 2024 12:39:35 +0000
Subject: [PATCH] fix: currentPart timeline dur respects postroll in autonext

---
 packages/job-worker/src/playout/timeline/piece.ts   | 2 +-
 packages/job-worker/src/playout/timeline/rundown.ts | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/packages/job-worker/src/playout/timeline/piece.ts b/packages/job-worker/src/playout/timeline/piece.ts
index 9e011a3348..861946f01d 100644
--- a/packages/job-worker/src/playout/timeline/piece.ts
+++ b/packages/job-worker/src/playout/timeline/piece.ts
@@ -106,7 +106,7 @@ export function getPieceEnableInsidePart(
 	if (partTimings.toPartPostroll) {
 		if (!pieceEnable.duration) {
 			// make sure that the control object is shortened correctly
-			pieceEnable.duration = `#${partGroupId} - ${partTimings.toPartPostroll}`
+			pieceEnable.end = `#${partGroupId} - ${partTimings.toPartPostroll}`
 		}
 	}
 
diff --git a/packages/job-worker/src/playout/timeline/rundown.ts b/packages/job-worker/src/playout/timeline/rundown.ts
index d8ee36ab7d..27299011a1 100644
--- a/packages/job-worker/src/playout/timeline/rundown.ts
+++ b/packages/job-worker/src/playout/timeline/rundown.ts
@@ -146,7 +146,8 @@ export function buildTimelineObjsForRundown(
 			// If there is a valid autonext out of the current part, then calculate the duration
 			currentPartEnable.duration =
 				partInstancesInfo.current.partInstance.part.expectedDuration +
-				partInstancesInfo.current.calculatedTimings.toPartDelay
+				partInstancesInfo.current.calculatedTimings.toPartDelay +
+				partInstancesInfo.current.calculatedTimings.toPartPostroll // autonext should have the postroll added to it to not confuse the timeline
 		}
 		const currentPartGroup = createPartGroup(partInstancesInfo.current.partInstance, currentPartEnable)