Skip to content

Commit bec0113

Browse files
rjmunroanteeek
authored andcommitted
fixup jobs for rest API
1 parent 30332ca commit bec0113

File tree

1 file changed

+16
-29
lines changed

1 file changed

+16
-29
lines changed

packages/job-worker/src/playout/tTimersJobs.ts

Lines changed: 16 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ export async function handleTTimerStartCountdown(_context: JobContext, data: TTi
2020
return runJobWithPlayoutModel(_context, data, null, async (playoutModel) => {
2121
validateTTimerIndex(data.timerIndex)
2222

23-
const timerMode = createCountdownTTimer(data.duration * 1000, {
24-
stopAtZero: data.stopAtZero,
25-
startPaused: data.startPaused,
26-
})
27-
2823
const currentTimer = playoutModel.playlist.tTimers[data.timerIndex - 1]
2924
playoutModel.updateTTimer({
3025
...currentTimer,
31-
mode: timerMode,
26+
...createCountdownTTimer(data.duration * 1000, {
27+
stopAtZero: data.stopAtZero,
28+
startPaused: data.startPaused,
29+
}),
3230
})
3331
})
3432
}
@@ -37,14 +35,12 @@ export async function handleTTimerStartFreeRun(_context: JobContext, data: TTime
3735
return runJobWithPlayoutModel(_context, data, null, async (playoutModel) => {
3836
validateTTimerIndex(data.timerIndex)
3937

40-
const timerMode = createFreeRunTTimer({
41-
startPaused: data.startPaused,
42-
})
43-
4438
const currentTimer = playoutModel.playlist.tTimers[data.timerIndex - 1]
4539
playoutModel.updateTTimer({
4640
...currentTimer,
47-
mode: timerMode,
41+
...createFreeRunTTimer({
42+
startPaused: data.startPaused,
43+
}),
4844
})
4945
})
5046
}
@@ -57,12 +53,9 @@ export async function handleTTimerPause(_context: JobContext, data: TTimerPauseP
5753
const currentTimer = playoutModel.playlist.tTimers[timerIndex]
5854
if (!currentTimer.mode) return
5955

60-
const newMode = pauseTTimer(currentTimer.mode)
61-
if (newMode) {
62-
playoutModel.updateTTimer({
63-
...currentTimer,
64-
mode: newMode,
65-
})
56+
const updatedTimer = pauseTTimer(currentTimer)
57+
if (updatedTimer) {
58+
playoutModel.updateTTimer(updatedTimer)
6659
}
6760
})
6861
}
@@ -75,12 +68,9 @@ export async function handleTTimerResume(_context: JobContext, data: TTimerResum
7568
const currentTimer = playoutModel.playlist.tTimers[timerIndex]
7669
if (!currentTimer.mode) return
7770

78-
const newMode = resumeTTimer(currentTimer.mode)
79-
if (newMode) {
80-
playoutModel.updateTTimer({
81-
...currentTimer,
82-
mode: newMode,
83-
})
71+
const updatedTimer = resumeTTimer(currentTimer)
72+
if (updatedTimer) {
73+
playoutModel.updateTTimer(updatedTimer)
8474
}
8575
})
8676
}
@@ -93,12 +83,9 @@ export async function handleTTimerRestart(_context: JobContext, data: TTimerRest
9383
const currentTimer = playoutModel.playlist.tTimers[timerIndex]
9484
if (!currentTimer.mode) return
9585

96-
const newMode = restartTTimer(currentTimer.mode)
97-
if (newMode) {
98-
playoutModel.updateTTimer({
99-
...currentTimer,
100-
mode: newMode,
101-
})
86+
const updatedTimer = restartTTimer(currentTimer)
87+
if (updatedTimer) {
88+
playoutModel.updateTTimer(updatedTimer)
10289
}
10390
})
10491
}

0 commit comments

Comments
 (0)