Skip to content

Commit

Permalink
chore: fix check-types
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Oct 10, 2023
1 parent ac19173 commit 3c90669
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 12 deletions.
8 changes: 4 additions & 4 deletions meteor/client/lib/__tests__/rundownTiming.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -656,13 +656,13 @@ describe('rundown Timing Calculator', () => {
partInstanceId: currentPartInstanceId,
rundownId: protectString<RundownId>(rundownId1),
manuallySelected: false,
consumesNextSegmentId: false,
consumesQueuedSegmentId: false,
}
playlist.nextPartInfo = {
partInstanceId: nextPartInstanceId,
rundownId: protectString<RundownId>(rundownId1),
manuallySelected: false,
consumesNextSegmentId: false,
consumesQueuedSegmentId: false,
}
const rundown = makeMockRundown(rundownId1, playlist)
const rundowns = [rundown]
Expand Down Expand Up @@ -813,13 +813,13 @@ describe('rundown Timing Calculator', () => {
partInstanceId: currentPartInstanceId,
rundownId: protectString<RundownId>(rundownId1),
manuallySelected: false,
consumesNextSegmentId: false,
consumesQueuedSegmentId: false,
}
playlist.nextPartInfo = {
partInstanceId: nextPartInstanceId,
rundownId: protectString<RundownId>(rundownId1),
manuallySelected: false,
consumesNextSegmentId: false,
consumesQueuedSegmentId: false,
}
const rundown = makeMockRundown(rundownId1, playlist)
const rundowns = [rundown]
Expand Down
2 changes: 1 addition & 1 deletion meteor/client/ui/MediaStatus/MediaStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function useRundownPlaylists(playlistIds: RundownPlaylistId[]) {
metaData: 0,
modified: 0,
nextPartInfo: 0,
nextSegmentId: 0,
queuedSegmentId: 0,
nextTimeOffset: 0,
previousPartInfo: 0,
previousPersistentState: 0,
Expand Down
2 changes: 1 addition & 1 deletion meteor/client/ui/RundownView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@ export const RundownView = translateWithTracker<IProps, IState, ITrackedProps>((

onSetNextSegment = (segmentId: SegmentId, e: any) => {
const { t } = this.props
if (this.state.studioMode && (segmentId || segmentId === null) && this.props.playlist) {
if (this.state.studioMode && segmentId && this.props.playlist) {
const playlistId = this.props.playlist._id
doUserAction(
t,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const SegmentScratchpadContainer = withResolvedSegment<IProps>(function S
playlist={props.playlist}
isLiveSegment={isLiveSegment}
isNextSegment={isNextSegment}
isQueuedSegment={props.playlist.nextSegmentId === props.segmentui._id}
isQueuedSegment={props.playlist.queuedSegmentId === props.segmentui._id}
hasRemoteItems={props.hasRemoteItems}
hasGuestItems={props.hasGuestItems}
currentPartWillAutoNext={currentPartWillAutoNext}
Expand Down
2 changes: 1 addition & 1 deletion meteor/client/ui/SegmentTimeline/SegmentContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/

interface IProps {
onSetNext: (part: DBPart | undefined, e: any, offset?: number, take?: boolean) => void
onSetNextSegment: (segmentId: SegmentId | null, e: any) => void
onSetNextSegment: (segmentId: SegmentId, e: any) => void
onQueueNextSegment: (segmentId: SegmentId | null, e: any) => void
playlist?: DBRundownPlaylist
studioMode: boolean
Expand Down
50 changes: 46 additions & 4 deletions meteor/server/api/rest/v1/playlists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '../../../collections'
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
import { ServerClientAPI } from '../../client'
import { StudioJobs } from '@sofie-automation/corelib/dist/worker/studio'
import { QueueNextSegmentResult, StudioJobs } from '@sofie-automation/corelib/dist/worker/studio'
import { getCurrentTime } from '../../../../lib/lib'
import { TriggerReloadDataResponse } from '../../../../lib/api/userActions'
import { ServerRundownAPI } from '../../rundown'
Expand Down Expand Up @@ -310,7 +310,7 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
event: string,
rundownPlaylistId: RundownPlaylistId,
segmentId: SegmentId
): Promise<ClientAPI.ClientResponse<void>> {
): Promise<ClientAPI.ClientResponse<PartId>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
Expand Down Expand Up @@ -350,6 +350,29 @@ class PlaylistsServerAPI implements PlaylistsRestAPI {
)
}

async queueNextSegment(
connection: Meteor.Connection,
event: string,
rundownPlaylistId: RundownPlaylistId,
segmentId: SegmentId
): Promise<ClientAPI.ClientResponse<QueueNextSegmentResult>> {
return ServerClientAPI.runUserActionInLogForPlaylistOnWorker(
this.context.getMethodContext(connection),
event,
getCurrentTime(),
rundownPlaylistId,
() => {
check(rundownPlaylistId, String)
check(segmentId, String)
},
StudioJobs.QueueNextSegment,
{
playlistId: rundownPlaylistId,
queuedSegmentId: segmentId,
}
)
}

async take(
connection: Meteor.Connection,
event: string,
Expand Down Expand Up @@ -606,8 +629,8 @@ export function registerRoutes(registerRoute: APIRegisterHook<PlaylistsRestAPI>)
}
)

registerRoute<{ playlistId: string }, { segmentId: string }, void>(
'put',
registerRoute<{ playlistId: string }, { segmentId: string }, PartId | null>(
'post',
'/playlists/:playlistId/set-next-segment',
new Map([
[404, [UserErrorMessage.RundownPlaylistNotFound]],
Expand All @@ -625,6 +648,25 @@ export function registerRoutes(registerRoute: APIRegisterHook<PlaylistsRestAPI>)
}
)

registerRoute<{ playlistId: string }, { segmentId: string }, QueueNextSegmentResult>(
'post',
'/playlists/:playlistId/queue-next-segment',
new Map([
[404, [UserErrorMessage.RundownPlaylistNotFound]],
[412, [UserErrorMessage.PartNotFound]],
]),
playlistsAPIFactory,
async (serverAPI, connection, event, params, body) => {
const rundownPlaylistId = protectString<RundownPlaylistId>(params.playlistId)
const segmentId = protectString<SegmentId>(body.segmentId)
logger.info(`API POST: set-next-segment ${rundownPlaylistId} ${segmentId}`)

check(rundownPlaylistId, String)
check(segmentId, String)
return await serverAPI.queueNextSegment(connection, event, rundownPlaylistId, segmentId)
}
)

registerRoute<{ playlistId: string }, { fromPartInstanceId?: string }, void>(
'post',
'/playlists/:playlistId/take',
Expand Down

0 comments on commit 3c90669

Please sign in to comment.