Skip to content

Commit 6d7de5e

Browse files
committed
feat(T-Timers): Add convenience method to set estimate anchor part by externalId
1 parent 9660143 commit 6d7de5e

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

packages/blueprints-integration/src/context/tTimersContext.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ export interface IPlaylistTTimer {
8888
*/
8989
setEstimateAnchorPart(partId: string): void
9090

91+
/**
92+
* Set the anchor part for automatic estimate calculation, looked up by its externalId.
93+
* This is a convenience method when you know the externalId of the part (e.g. set during ingest)
94+
* but not its internal PartId. If no part with the given externalId is found, this is a no-op.
95+
* Clears any manual estimate set via setEstimateTime/setEstimateDuration.
96+
* @param externalId The externalId of the part to use as timing anchor
97+
*/
98+
setEstimateAnchorPartByExternalId(externalId: string): void
99+
91100
/**
92101
* Manually set the estimate as an absolute timestamp
93102
* Use this when you have custom logic for calculating when you expect to reach a timing point.

packages/job-worker/src/blueprints/context/services/TTimersService.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { RundownTTimer, RundownTTimerIndex } from '@sofie-automation/coreli
66
import type { TimerState } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
77
import type { PartId } from '@sofie-automation/corelib/dist/dataModel/Ids'
88
import { assertNever, literal } from '@sofie-automation/corelib/dist/lib'
9-
import { protectString } from '@sofie-automation/corelib/dist/protectedString'
9+
import { protectString, unprotectString } from '@sofie-automation/corelib/dist/protectedString'
1010
import type { PlayoutModel } from '../../../playout/model/PlayoutModel.js'
1111
import { ReadonlyDeep } from 'type-fest'
1212
import {
@@ -213,6 +213,13 @@ export class PlaylistTTimerImpl implements IPlaylistTTimer {
213213
recalculateTTimerEstimates(this.#jobContext, this.#playoutModel)
214214
}
215215

216+
setEstimateAnchorPartByExternalId(externalId: string): void {
217+
const part = this.#playoutModel.getAllOrderedParts().find((p) => p.externalId === externalId)
218+
if (!part) return
219+
220+
this.setEstimateAnchorPart(unprotectString(part._id))
221+
}
222+
216223
setEstimateTime(time: number, paused: boolean = false): void {
217224
const estimateState: TimerState = paused
218225
? literal<TimerState>({ paused: true, duration: time - getCurrentTime() })

0 commit comments

Comments
 (0)