Skip to content

Commit 38f4423

Browse files
committed
chore: move logic to client
1 parent e95fedd commit 38f4423

39 files changed

+107
-128
lines changed

meteor/lib/Rundown.ts renamed to meteor/client/lib/RundownResolver.ts

Lines changed: 8 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
import { Piece } from '@sofie-automation/corelib/dist/dataModel/Piece'
2-
import { IOutputLayer, ISourceLayer, ITranslatableMessage } from '@sofie-automation/blueprints-integration'
2+
import { IOutputLayer, ISourceLayer } from '@sofie-automation/blueprints-integration'
33
import { DBSegment, SegmentOrphanedReason } from '@sofie-automation/corelib/dist/dataModel/Segment'
44
import { DBPart } from '@sofie-automation/corelib/dist/dataModel/Part'
5-
import { PartInstance, wrapPartToTemporaryInstance } from './collections/PartInstances'
5+
import { PartInstance, wrapPartToTemporaryInstance } from '../../lib/collections/PartInstances'
66
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
77
import {
88
getPieceInstancesForPart,
99
buildPiecesStartingInThisPartQuery,
1010
buildPastInfinitePiecesForThisPartQuery,
1111
} from '@sofie-automation/corelib/dist/playout/infinites'
12-
import { invalidateAfter } from '../lib/invalidatingTime'
13-
import { getCurrentTime, groupByToMap, ProtectedString, protectString } from './lib'
12+
import { invalidateAfter } from '../../lib/invalidatingTime'
13+
import { getCurrentTime, groupByToMap, protectString } from '../../lib/lib'
1414
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
1515
import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'
16-
import { isTranslatableMessage } from '@sofie-automation/corelib/dist/TranslatableMessage'
1716
import { mongoWhereFilter, MongoQuery } from '@sofie-automation/corelib/dist/mongo'
18-
import { FindOptions } from './collections/lib'
17+
import { FindOptions } from '../../lib/collections/lib'
1918
import {
2019
PartId,
2120
RundownId,
2221
RundownPlaylistActivationId,
2322
SegmentId,
2423
ShowStyleBaseId,
2524
} from '@sofie-automation/corelib/dist/dataModel/Ids'
26-
import { PieceInstances, Pieces } from './collections/libCollections'
27-
import { RundownPlaylistCollectionUtil } from './collections/rundownPlaylistUtil'
28-
import { PieceContentStatusObj } from './api/pieceContentStatus'
25+
import { PieceInstances, Pieces } from '../../lib/collections/libCollections'
26+
import { RundownPlaylistCollectionUtil } from '../../lib/collections/rundownPlaylistUtil'
27+
import { PieceContentStatusObj } from '../../lib/api/pieceContentStatus'
2928
import { ReadonlyDeep } from 'type-fest'
3029
import { PieceInstanceWithTimings } from '@sofie-automation/corelib/dist/playout/processAndPrune'
3130

@@ -322,85 +321,3 @@ export function getSegmentsWithPartInstances(
322321
}
323322
})
324323
}
325-
326-
// 1 reactivelly listen to data changes
327-
/*
328-
setup () {
329-
RundownPlaylists.find().observeChanges(
330-
asdf: onReactiveDataChange
331-
)
332-
}
333-
334-
onReactiveDataChange () {
335-
setTimeoutIgnore(() => {
336-
updateCalculatedData()
337-
}, 200)
338-
}
339-
340-
const cachedSegments = {}
341-
updateCalculatedData () {
342-
343-
const data = calculateBigDataSet()
344-
345-
data.segments
346-
}
347-
*/
348-
349-
function compareLabels(a: string | ITranslatableMessage, b: string | ITranslatableMessage) {
350-
const actualA = isTranslatableMessage(a) ? a.key : (a as string)
351-
const actualB = isTranslatableMessage(b) ? b.key : (b as string)
352-
// can't use .localeCompare, because this needs to be locale-independent and always return
353-
// the same sorting order, because that's being relied upon by limit & pick/pickEnd.
354-
if (actualA > actualB) return 1
355-
if (actualA < actualB) return -1
356-
return 0
357-
}
358-
359-
/** Sort a list of adlibs */
360-
export function sortAdlibs<T>(
361-
adlibs: {
362-
adlib: T
363-
label: string | ITranslatableMessage
364-
adlibRank: number
365-
adlibId: ProtectedString<any> | string
366-
partRank: number | null
367-
segmentRank: number | null
368-
rundownRank: number | null
369-
}[]
370-
): T[] {
371-
adlibs = adlibs.sort((a, b) => {
372-
// Sort by rundown rank, where applicable:
373-
a.rundownRank = a.rundownRank ?? Number.POSITIVE_INFINITY
374-
b.rundownRank = b.rundownRank ?? Number.POSITIVE_INFINITY
375-
if (a.rundownRank > b.rundownRank) return 1
376-
if (a.rundownRank < b.rundownRank) return -1
377-
378-
// Sort by segment rank, where applicable:
379-
a.segmentRank = a.segmentRank ?? Number.POSITIVE_INFINITY
380-
b.segmentRank = b.segmentRank ?? Number.POSITIVE_INFINITY
381-
if (a.segmentRank > b.segmentRank) return 1
382-
if (a.segmentRank < b.segmentRank) return -1
383-
384-
// Sort by part rank, where applicable:
385-
a.partRank = a.partRank ?? Number.POSITIVE_INFINITY
386-
b.partRank = b.partRank ?? Number.POSITIVE_INFINITY
387-
if (a.partRank > b.partRank) return 1
388-
if (a.partRank < b.partRank) return -1
389-
390-
// Sort by adlib rank
391-
if (a.adlibRank > b.adlibRank) return 1
392-
if (a.adlibRank < b.adlibRank) return -1
393-
394-
// Sort by labels:
395-
const r = compareLabels(a.label, b.label)
396-
if (r !== 0) return r
397-
398-
// As a last resort, sort by ids:
399-
if (a.adlibId > b.adlibId) return 1
400-
if (a.adlibId < b.adlibId) return -1
401-
402-
return 0
403-
})
404-
405-
return adlibs.map((a) => a.adlib)
406-
}

meteor/client/lib/rundown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
ISourceLayerExtended,
2020
PartInstanceLimited,
2121
getSegmentsWithPartInstances,
22-
} from '../../lib/Rundown'
22+
} from './RundownResolver'
2323
import { PartInstance } from '../../lib/collections/PartInstances'
2424
import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
2525
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'

meteor/client/ui/ClockView/CameraScreen/Part.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import classNames from 'classnames'
33
import React, { useContext } from 'react'
44
import { AreaZoom } from '.'
55
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
6-
import { PieceExtended } from '../../../../lib/Rundown'
6+
import { PieceExtended } from '../../../lib/RundownResolver'
77
import { getAllowSpeaking, getAllowVibrating } from '../../../lib/localStorage'
88
import { getPartInstanceTimingValue } from '../../../lib/rundownTiming'
99
import { AutoNextStatus } from '../../RundownView/RundownTiming/AutoNextStatus'

meteor/client/ui/ClockView/CameraScreen/Piece.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React, { useContext, useMemo } from 'react'
22
import { PartId } from '@sofie-automation/corelib/dist/dataModel/Ids'
33
import classNames from 'classnames'
44
import { CanvasSizeContext } from '.'
5-
import { PieceExtended } from '../../../../lib/Rundown'
5+
import { PieceExtended } from '../../../lib/RundownResolver'
66
import { PieceElement } from '../../SegmentContainer/PieceElement'
77
import { getSplitItems } from '../../SegmentContainer/getSplitItems'
88

meteor/client/ui/ClockView/CameraScreen/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { unprotectString } from '@sofie-automation/corelib/dist/protectedString'
66
import { MeteorPubSub } from '../../../../lib/api/pubsub'
77
import { UIStudio } from '../../../../lib/api/studios'
88
import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
9-
import { PieceExtended } from '../../../../lib/Rundown'
9+
import { PieceExtended } from '../../../lib/RundownResolver'
1010
import { PartInstances, Rundowns } from '../../../collections'
1111
import { useSubscription, useTracker } from '../../../lib/ReactMeteorData/ReactMeteorData'
1212
import { UIStudios } from '../../Collections'

meteor/client/ui/MediaStatus/MediaStatus.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useMemo, JSX } from 'react'
22
import { useSubscription, useSubscriptions, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData'
33
import { MeteorPubSub } from '../../../lib/api/pubsub'
4-
import { getSegmentsWithPartInstances } from '../../../lib/Rundown'
4+
import { getSegmentsWithPartInstances } from '../../lib/RundownResolver'
55
import {
66
AdLibActionId,
77
PartId,

meteor/client/ui/PieceIcons/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { SourceLayerType, ISourceLayer } from '@sofie-automation/blueprints-inte
22
import { SourceLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase'
33
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
44
import { IPropsHeader } from './PieceIcon'
5-
import { PieceExtended } from '../../../lib/Rundown'
5+
import { PieceExtended } from '../../lib/RundownResolver'
66
import { UIShowStyleBases } from '../Collections'
77
import { PieceInstances } from '../../collections'
88
import { ReadonlyDeep } from 'type-fest'

meteor/client/ui/Prompter/prompter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as _ from 'underscore'
33
import { ScriptContent, SourceLayerType } from '@sofie-automation/blueprints-integration'
44
import { normalizeArrayToMap, protectString } from '../../../lib/lib'
55
import { Piece } from '@sofie-automation/corelib/dist/dataModel/Piece'
6-
import { getPieceInstancesForPartInstance, getSegmentsWithPartInstances } from '../../../lib/Rundown'
6+
import { getPieceInstancesForPartInstance, getSegmentsWithPartInstances } from '../../lib/RundownResolver'
77
import { FindOptions } from '../../../lib/collections/lib'
88
import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance'
99
import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown'

meteor/client/ui/SegmentContainer/PieceElement.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22
import { ISourceLayer } from '@sofie-automation/blueprints-integration'
3-
import { PieceExtended } from '../../../lib/Rundown'
3+
import { PieceExtended } from '../../lib/RundownResolver'
44
import { pieceUiClassNames } from '../../lib/ui/pieceUiClassNames'
55
import { PartId } from '@sofie-automation/corelib/dist/dataModel/Ids'
66

meteor/client/ui/SegmentContainer/PieceMultistepChevron.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NoraContent, SourceLayerType } from '@sofie-automation/blueprints-integration'
22
import React from 'react'
3-
import { PieceExtended } from '../../../lib/Rundown'
3+
import { PieceExtended } from '../../lib/RundownResolver'
44

55
export const PieceMultistepChevron = React.forwardRef<
66
HTMLSpanElement,

0 commit comments

Comments
 (0)