@@ -26,7 +26,7 @@ import {
2626import { DeviceActions } from '@sofie-automation/shared-lib/dist/core/model/ShowStyle'
2727import { UserError , UserErrorMessage } from '@sofie-automation/corelib/dist/error'
2828import { MountedAdLibTriggerType } from '../api/MountedTriggers'
29- import { DummyReactiveVar , ReactiveVar } from './reactive-var'
29+ import { DummyReactiveVar , TriggerReactiveVar } from './reactive-var'
3030import { TriggersContext , TriggerTrackerComputation } from './triggersContext'
3131import { assertNever } from '@sofie-automation/corelib/dist/lib'
3232
@@ -36,18 +36,18 @@ type Without<T, U> = { [P in Exclude<keyof T, keyof U>]?: never }
3636type XOR < T , U > = T | U extends object ? ( Without < T , U > & U ) | ( Without < U , T > & T ) : T | U
3737
3838export interface ReactivePlaylistActionContext {
39- studioId : ReactiveVar < StudioId >
40- rundownPlaylistId : ReactiveVar < RundownPlaylistId >
41- rundownPlaylist : ReactiveVar <
39+ studioId : TriggerReactiveVar < StudioId >
40+ rundownPlaylistId : TriggerReactiveVar < RundownPlaylistId >
41+ rundownPlaylist : TriggerReactiveVar <
4242 Pick < DBRundownPlaylist , '_id' | 'name' | 'activationId' | 'nextPartInfo' | 'currentPartInfo' >
4343 >
4444
45- currentRundownId : ReactiveVar < RundownId | null >
46- currentSegmentPartIds : ReactiveVar < PartId [ ] >
47- nextSegmentPartIds : ReactiveVar < PartId [ ] >
48- currentPartInstanceId : ReactiveVar < PartInstanceId | null >
49- currentPartId : ReactiveVar < PartId | null >
50- nextPartId : ReactiveVar < PartId | null >
45+ currentRundownId : TriggerReactiveVar < RundownId | null >
46+ currentSegmentPartIds : TriggerReactiveVar < PartId [ ] >
47+ nextSegmentPartIds : TriggerReactiveVar < PartId [ ] >
48+ currentPartInstanceId : TriggerReactiveVar < PartInstanceId | null >
49+ currentPartId : TriggerReactiveVar < PartId | null >
50+ nextPartId : TriggerReactiveVar < PartId | null >
5151}
5252
5353interface PlainPlaylistContext {
@@ -111,7 +111,6 @@ async function createRundownPlaylistContext(
111111 if ( filterChain . length < 1 ) {
112112 return undefined
113113 } else if ( filterChain [ 0 ] . object === 'view' && context . rundownPlaylistId ) {
114- // nocommit - rewrap to track on this computation?
115114 return context as ReactivePlaylistActionContext
116115 } else if ( filterChain [ 0 ] . object === 'view' && context . rundownPlaylist ) {
117116 const playlistContext = context as PlainPlaylistContext
@@ -180,11 +179,11 @@ function createAdLibAction(
180179 )
181180 return
182181 }
183- const currentPartInstanceId = innerCtx . rundownPlaylist . get ( ) . currentPartInfo ?. partInstanceId
182+ const currentPartInstanceId = innerCtx . rundownPlaylist . get ( null ) . currentPartInfo ?. partInstanceId
184183
185184 const sourceLayerIdsToClear : string [ ] = [ ]
186185
187- // nocommit - discard the withComputation?
186+ // This withComputation is probably not needed, but is a nice safeguard
188187 const wrappedAdLibs = await triggersContext . withComputation ( null , async ( ) =>
189188 compiledAdLibFilter ( innerCtx , null )
190189 )
@@ -197,7 +196,7 @@ function createAdLibAction(
197196 ? triggersContext . MeteorCall . userAction . segmentAdLibPieceStart (
198197 e ,
199198 ts ,
200- innerCtx . rundownPlaylistId . get ( ) ,
199+ innerCtx . rundownPlaylistId . get ( null ) ,
201200 currentPartInstanceId ,
202201 wrappedAdLib . item . _id ,
203202 false
@@ -211,7 +210,7 @@ function createAdLibAction(
211210 ? triggersContext . MeteorCall . userAction . baselineAdLibPieceStart (
212211 e ,
213212 ts ,
214- innerCtx . rundownPlaylistId . get ( ) ,
213+ innerCtx . rundownPlaylistId . get ( null ) ,
215214 currentPartInstanceId ,
216215 wrappedAdLib . item . _id ,
217216 false
@@ -224,7 +223,7 @@ function createAdLibAction(
224223 triggersContext . MeteorCall . userAction . executeAction (
225224 e ,
226225 ts ,
227- innerCtx . rundownPlaylistId . get ( ) ,
226+ innerCtx . rundownPlaylistId . get ( null ) ,
228227 wrappedAdLib . _id ,
229228 wrappedAdLib . item . actionId ,
230229 wrappedAdLib . item . userData ,
@@ -237,7 +236,7 @@ function createAdLibAction(
237236 triggersContext . MeteorCall . userAction . executeAction (
238237 e ,
239238 ts ,
240- innerCtx . rundownPlaylistId . get ( ) ,
239+ innerCtx . rundownPlaylistId . get ( null ) ,
241240 wrappedAdLib . _id ,
242241 wrappedAdLib . item . actionId ,
243242 wrappedAdLib . item . userData ,
@@ -254,7 +253,7 @@ function createAdLibAction(
254253 triggersContext . MeteorCall . userAction . sourceLayerStickyPieceStart (
255254 e ,
256255 ts ,
257- innerCtx . rundownPlaylistId . get ( ) ,
256+ innerCtx . rundownPlaylistId . get ( null ) ,
258257 wrappedAdLib . sourceLayerId //
259258 )
260259 )
@@ -270,7 +269,7 @@ function createAdLibAction(
270269 triggersContext . MeteorCall . userAction . sourceLayerOnPartStop (
271270 e ,
272271 ts ,
273- innerCtx . rundownPlaylistId . get ( ) ,
272+ innerCtx . rundownPlaylistId . get ( null ) ,
274273 currentPartInstanceId ,
275274 sourceLayerIdsToClear
276275 )
@@ -463,7 +462,7 @@ export function createAction(
463462 triggersContext . MeteorCall . userAction . forceResetAndActivate (
464463 e ,
465464 ts ,
466- ctx . rundownPlaylistId . get ( ) ,
465+ ctx . rundownPlaylistId . get ( null ) ,
467466 ! ! action . rehearsal || false
468467 )
469468 )
@@ -482,7 +481,7 @@ export function createAction(
482481 triggersContext . MeteorCall . userAction . activate (
483482 e ,
484483 ts ,
485- ctx . rundownPlaylistId . get ( ) ,
484+ ctx . rundownPlaylistId . get ( null ) ,
486485 ! ! action . rehearsal || false
487486 )
488487 )
@@ -497,20 +496,20 @@ export function createAction(
497496 action ,
498497 UserAction . DEACTIVATE_RUNDOWN_PLAYLIST ,
499498 async ( e , ts , ctx ) =>
500- triggersContext . MeteorCall . userAction . deactivate ( e , ts , ctx . rundownPlaylistId . get ( ) )
499+ triggersContext . MeteorCall . userAction . deactivate ( e , ts , ctx . rundownPlaylistId . get ( null ) )
501500 )
502501 case PlayoutActions . activateAdlibTestingMode :
503502 return createUserActionWithCtx (
504503 triggersContext ,
505504 action ,
506505 UserAction . ACTIVATE_ADLIB_TESTING ,
507506 async ( e , ts , ctx ) => {
508- const rundownId = ctx . currentRundownId . get ( )
507+ const rundownId = ctx . currentRundownId . get ( null )
509508 if ( rundownId ) {
510509 return triggersContext . MeteorCall . userAction . activateAdlibTestingMode (
511510 e ,
512511 ts ,
513- ctx . rundownPlaylistId . get ( ) ,
512+ ctx . rundownPlaylistId . get ( null ) ,
514513 rundownId
515514 )
516515 } else {
@@ -526,21 +525,26 @@ export function createAction(
526525 triggersContext . MeteorCall . userAction . take (
527526 e ,
528527 ts ,
529- ctx . rundownPlaylistId . get ( ) ,
530- ctx . currentPartInstanceId . get ( )
528+ ctx . rundownPlaylistId . get ( null ) ,
529+ ctx . currentPartInstanceId . get ( null )
531530 )
532531 )
533532 }
534533 case PlayoutActions . hold :
535534 return createUserActionWithCtx ( triggersContext , action , UserAction . ACTIVATE_HOLD , async ( e , ts , ctx ) =>
536- triggersContext . MeteorCall . userAction . activateHold ( e , ts , ctx . rundownPlaylistId . get ( ) , ! ! action . undo )
535+ triggersContext . MeteorCall . userAction . activateHold (
536+ e ,
537+ ts ,
538+ ctx . rundownPlaylistId . get ( null ) ,
539+ ! ! action . undo
540+ )
537541 )
538542 case PlayoutActions . disableNextPiece :
539543 return createUserActionWithCtx ( triggersContext , action , UserAction . DISABLE_NEXT_PIECE , async ( e , ts , ctx ) =>
540544 triggersContext . MeteorCall . userAction . disableNextPiece (
541545 e ,
542546 ts ,
543- ctx . rundownPlaylistId . get ( ) ,
547+ ctx . rundownPlaylistId . get ( null ) ,
544548 ! ! action . undo
545549 )
546550 )
@@ -559,7 +563,7 @@ export function createAction(
559563 e ,
560564 ts ,
561565 triggersContext . hashSingleUseToken ( tokenResult . result ) ,
562- ctx . rundownPlaylistId . get ( ) ,
566+ ctx . rundownPlaylistId . get ( null ) ,
563567 `action` ,
564568 false
565569 )
@@ -571,7 +575,7 @@ export function createAction(
571575 triggersContext . MeteorCall . userAction . moveNext (
572576 e ,
573577 ts ,
574- ctx . rundownPlaylistId . get ( ) ,
578+ ctx . rundownPlaylistId . get ( null ) ,
575579 action . parts ?? 0 ,
576580 action . segments ?? 0
577581 )
@@ -587,7 +591,11 @@ export function createAction(
587591 async ( e , ts , ctx ) =>
588592 // TODO: Needs some handling of the response. Perhaps this should switch to
589593 // an event on the RundownViewEventBus, if ran on the client?
590- triggersContext . MeteorCall . userAction . resyncRundownPlaylist ( e , ts , ctx . rundownPlaylistId . get ( ) )
594+ triggersContext . MeteorCall . userAction . resyncRundownPlaylist (
595+ e ,
596+ ts ,
597+ ctx . rundownPlaylistId . get ( null )
598+ )
591599 )
592600 }
593601 case PlayoutActions . resetRundownPlaylist :
@@ -599,7 +607,11 @@ export function createAction(
599607 action ,
600608 UserAction . RESET_RUNDOWN_PLAYLIST ,
601609 async ( e , ts , ctx ) =>
602- triggersContext . MeteorCall . userAction . resetRundownPlaylist ( e , ts , ctx . rundownPlaylistId . get ( ) )
610+ triggersContext . MeteorCall . userAction . resetRundownPlaylist (
611+ e ,
612+ ts ,
613+ ctx . rundownPlaylistId . get ( null )
614+ )
603615 )
604616 }
605617 case PlayoutActions . resyncRundownPlaylist :
@@ -608,14 +620,14 @@ export function createAction(
608620 action ,
609621 UserAction . RESYNC_RUNDOWN_PLAYLIST ,
610622 async ( e , ts , ctx ) =>
611- triggersContext . MeteorCall . userAction . resyncRundownPlaylist ( e , ts , ctx . rundownPlaylistId . get ( ) )
623+ triggersContext . MeteorCall . userAction . resyncRundownPlaylist ( e , ts , ctx . rundownPlaylistId . get ( null ) )
612624 )
613625 case PlayoutActions . switchRouteSet :
614626 return createUserActionWithCtx ( triggersContext , action , UserAction . SWITCH_ROUTE_SET , async ( e , ts , ctx ) =>
615627 triggersContext . MeteorCall . userAction . switchRouteSet (
616628 e ,
617629 ts ,
618- ctx . studioId . get ( ) ,
630+ ctx . studioId . get ( null ) ,
619631 action . routeSetId ,
620632 action . state
621633 )
0 commit comments