From e9286d6c574700977eaeb85a87e0a5b827cad5c4 Mon Sep 17 00:00:00 2001 From: Julian Waller Date: Fri, 27 Oct 2023 11:52:19 +0200 Subject: [PATCH 1/3] feat: typed publications in gateways/peripheraldevices --- .../lib/ConnectionStatusNotification.tsx | 4 +- meteor/client/lib/MeteorReactComponent.ts | 7 +- .../lib/ReactMeteorData/ReactMeteorData.tsx | 11 +- .../lib/reactiveData/reactiveDataHelper.ts | 4 +- .../client/lib/triggers/TriggersHandler.tsx | 19 +- meteor/client/ui/Account/OrganizationPage.tsx | 4 +- meteor/client/ui/ActiveRundownView.tsx | 7 +- meteor/client/ui/App.tsx | 6 +- .../client/ui/ClipTrimPanel/ClipTrimPanel.tsx | 4 +- .../ui/ClockView/CameraScreen/Rundown.tsx | 4 +- .../ui/ClockView/CameraScreen/index.tsx | 17 +- meteor/client/ui/ClockView/ClockView.tsx | 4 +- .../ui/ClockView/OverlayScreenSaver.tsx | 7 +- .../client/ui/ClockView/PresenterScreen.tsx | 23 +- meteor/client/ui/MediaStatus/MediaStatus.tsx | 29 +- .../client/ui/PieceIcons/PieceCountdown.tsx | 7 +- meteor/client/ui/PieceIcons/PieceIcon.tsx | 7 +- meteor/client/ui/PieceIcons/PieceName.tsx | 7 +- meteor/client/ui/Prompter/PrompterView.tsx | 23 +- meteor/client/ui/RundownList.tsx | 15 +- meteor/client/ui/RundownView.tsx | 41 +-- .../client/ui/RundownView/RundownNotifier.tsx | 7 +- .../ui/RundownView/RundownSystemStatus.tsx | 4 +- .../LinePartAdLibIndicator.tsx | 6 +- .../ui/SegmentList/SegmentListContainer.tsx | 9 +- .../SegmentScratchpadContainer.tsx | 9 +- .../SegmentStoryboardContainer.tsx | 9 +- .../SegmentTimelineContainer.tsx | 9 +- meteor/client/ui/Settings.tsx | 12 +- .../ui/Settings/RundownLayoutEditor.tsx | 4 +- meteor/client/ui/Settings/SettingsMenu.tsx | 13 +- .../BlueprintConfiguration/index.tsx | 4 +- meteor/client/ui/Settings/SnapshotsView.tsx | 7 +- .../Studio/BlueprintConfiguration/index.tsx | 4 +- .../client/ui/Settings/SystemManagement.tsx | 4 +- meteor/client/ui/Settings/Upgrades/View.tsx | 4 +- .../TriggeredActionsEditor.tsx | 13 +- .../triggerEditors/DeviceEditor.tsx | 4 +- meteor/client/ui/Shelf/BucketPanel.tsx | 15 +- meteor/client/ui/Shelf/DashboardPanel.tsx | 4 +- meteor/client/ui/Status.tsx | 11 +- meteor/client/ui/Status/Evaluations.tsx | 4 +- meteor/client/ui/Status/ExternalMessages.tsx | 7 +- meteor/client/ui/Status/MediaManager.tsx | 6 +- meteor/client/ui/Status/SystemStatus.tsx | 4 +- meteor/client/ui/Status/UserActivity.tsx | 4 +- .../client/ui/Status/media-status/index.tsx | 4 +- .../client/ui/Status/package-status/index.tsx | 10 +- .../StudioScreenSaver/StudioScreenSaver.tsx | 7 +- meteor/client/ui/TestTools/DeviceTriggers.tsx | 21 +- meteor/client/ui/TestTools/Mappings.tsx | 11 +- meteor/client/ui/TestTools/Timeline.tsx | 11 +- .../client/ui/TestTools/TimelineDatastore.tsx | 4 +- meteor/client/ui/TestTools/index.tsx | 9 +- meteor/client/ui/i18n.ts | 4 +- meteor/lib/api/__tests__/pubsub.test.ts | 24 +- meteor/lib/api/pubsub.ts | 306 ++++++------------ meteor/lib/collections/lib.ts | 33 +- meteor/server/api/rest/v0/index.ts | 18 +- .../server/lib/customPublication/publish.ts | 18 +- meteor/server/publications/_publications.ts | 24 ++ .../blueprintUpgradeStatus/publication.ts | 6 +- meteor/server/publications/buckets.ts | 32 +- .../publications/deviceTriggersPreview.ts | 8 +- meteor/server/publications/lib.ts | 14 +- meteor/server/publications/mountedTriggers.ts | 13 +- meteor/server/publications/organization.ts | 50 +-- .../expectedPackages/publication.ts | 11 +- .../packageManager/packageContainers.ts | 11 +- .../packageManager/playoutContext.ts | 11 +- .../server/publications/peripheralDevice.ts | 27 +- .../publications/peripheralDeviceForDevice.ts | 11 +- .../bucket/publication.ts | 6 +- .../rundown/publication.ts | 6 +- meteor/server/publications/rundown.ts | 123 ++++--- meteor/server/publications/rundownPlaylist.ts | 4 +- .../segmentPartNotesUI/publication.ts | 6 +- meteor/server/publications/showStyle.ts | 11 +- meteor/server/publications/showStyleUI.ts | 6 +- meteor/server/publications/studio.ts | 27 +- meteor/server/publications/studioUI.ts | 38 ++- meteor/server/publications/system.ts | 39 +-- meteor/server/publications/timeline.ts | 42 ++- .../publications/translationsBundles.ts | 4 +- .../server/publications/triggeredActionsUI.ts | 6 +- .../src/documents/expectedPlayoutItem.ts | 14 +- packages/corelib/src/pubsub.ts | 209 ++++++++++++ .../src/collections/adLibActions.ts | 24 +- .../src/collections/adLibs.ts | 24 +- .../src/collections/globalAdLibActions.ts | 28 +- .../src/collections/globalAdLibs.ts | 28 +- .../src/collections/part.ts | 28 +- .../src/collections/partInstances.ts | 34 +- .../src/collections/playlist.ts | 33 +- .../src/collections/rundownHandler.ts | 23 +- .../src/collections/rundownsHandler.ts | 5 +- .../src/collections/segmentHandler.ts | 18 +- .../src/collections/segmentsHandler.ts | 5 +- .../src/collections/showStyleBase.ts | 24 +- .../src/collections/studio.ts | 27 +- .../live-status-gateway/src/coreHandler.ts | 74 +++-- packages/live-status-gateway/src/wsHandler.ts | 34 +- .../mos-gateway/src/CoreMosDeviceHandler.ts | 7 +- packages/mos-gateway/src/coreHandler.ts | 40 +-- packages/mos-gateway/src/mosHandler.ts | 13 +- packages/playout-gateway/src/coreHandler.ts | 105 ++---- packages/playout-gateway/src/tsrHandler.ts | 81 +++-- packages/server-core-integration/README.md | 4 +- .../examples/client.ts | 6 +- .../src/__tests__/index.spec.ts | 14 +- packages/server-core-integration/src/index.ts | 1 + .../src/integrationTests/index.spec.ts | 15 +- .../src/lib/CoreConnectionChild.ts | 38 ++- .../src/lib/coreConnection.ts | 49 +-- .../src/lib/ddpClient.ts | 38 +-- .../src/lib/subscriptions.ts | 28 +- .../shared-lib/src/expectedPlayoutItem.ts | 24 ++ .../shared-lib/src/pubsub/peripheralDevice.ts | 139 ++++++++ 118 files changed, 1591 insertions(+), 1086 deletions(-) create mode 100644 packages/corelib/src/pubsub.ts create mode 100644 packages/shared-lib/src/expectedPlayoutItem.ts create mode 100644 packages/shared-lib/src/pubsub/peripheralDevice.ts diff --git a/meteor/client/lib/ConnectionStatusNotification.tsx b/meteor/client/lib/ConnectionStatusNotification.tsx index 0850522e35..1f21207093 100644 --- a/meteor/client/lib/ConnectionStatusNotification.tsx +++ b/meteor/client/lib/ConnectionStatusNotification.tsx @@ -16,7 +16,7 @@ import { import { WithManagedTracker } from './reactiveData/reactiveDataHelper' import { withTranslation } from 'react-i18next' import { NotificationCenterPopUps } from './notifications/NotificationCenterPanel' -import { PubSub } from '../../lib/api/pubsub' +import { MeteorPubSub } from '../../lib/api/pubsub' import { ICoreSystem, ServiceMessage, Criticality } from '../../lib/collections/CoreSystem' import { TFunction } from 'react-i18next' import { getRandomId } from '@sofie-automation/corelib/dist/lib' @@ -31,7 +31,7 @@ export class ConnectionStatusNotifier extends WithManagedTracker { constructor(t: TFunction) { super() - this.subscribe(PubSub.coreSystem) + this.subscribe(MeteorPubSub.coreSystem) this._translator = t diff --git a/meteor/client/lib/MeteorReactComponent.ts b/meteor/client/lib/MeteorReactComponent.ts index 5f4895cd70..82c2a0fb5b 100644 --- a/meteor/client/lib/MeteorReactComponent.ts +++ b/meteor/client/lib/MeteorReactComponent.ts @@ -2,7 +2,7 @@ import { Tracker } from 'meteor/tracker' import * as React from 'react' import { stringifyObjects } from '../../lib/lib' import { Meteor } from 'meteor/meteor' -import { PubSubTypes } from '../../lib/api/pubsub' +import { AllPubSubTypes } from '../../lib/api/pubsub' import { catchError } from './lib' export class MeteorReactComponent extends React.Component { private _subscriptions: { [id: string]: Meteor.SubscriptionHandle } = {} @@ -14,7 +14,10 @@ export class MeteorReactComponent extends React.Component(name: K, ...args: Parameters): Meteor.SubscriptionHandle { + subscribe( + name: K, + ...args: Parameters + ): Meteor.SubscriptionHandle { return Tracker.nonreactive(() => { // let id = name + '_' + JSON.stringify(args.join()) const id = name + '_' + stringifyObjects(args) diff --git a/meteor/client/lib/ReactMeteorData/ReactMeteorData.tsx b/meteor/client/lib/ReactMeteorData/ReactMeteorData.tsx index abc8924c63..55eb4d9d72 100644 --- a/meteor/client/lib/ReactMeteorData/ReactMeteorData.tsx +++ b/meteor/client/lib/ReactMeteorData/ReactMeteorData.tsx @@ -6,7 +6,7 @@ import { Mongo } from 'meteor/mongo' import { Tracker } from 'meteor/tracker' import { withTranslation, WithTranslation } from 'react-i18next' import { MeteorReactComponent } from '../MeteorReactComponent' -import { meteorSubscribe, PubSubTypes } from '../../../lib/api/pubsub' +import { meteorSubscribe, AllPubSubTypes } from '../../../lib/api/pubsub' import { stringifyObjects } from '../../../lib/lib' const globalTrackerQueue: Array = [] @@ -340,7 +340,10 @@ export function useTracker( * @param {...any[]} args A list of arugments for the subscription. This is used for optimizing the subscription across * renders so that it isn't torn down and created for every render. */ -export function useSubscription(sub: K, ...args: Parameters): boolean { +export function useSubscription( + sub: K, + ...args: Parameters +): boolean { const [ready, setReady] = useState(false) useEffect(() => { @@ -359,9 +362,9 @@ export function useSubscription(sub: K, ...args: Pa /** * Sets up multiple subscriptions of the same type, but with different arguments */ -export function useSubscriptions( +export function useSubscriptions( sub: K, - argsArray: Parameters[] + argsArray: Parameters[] ): boolean { const [ready, setReady] = useState(false) diff --git a/meteor/client/lib/reactiveData/reactiveDataHelper.ts b/meteor/client/lib/reactiveData/reactiveDataHelper.ts index 4215a65f74..965e5083d5 100644 --- a/meteor/client/lib/reactiveData/reactiveDataHelper.ts +++ b/meteor/client/lib/reactiveData/reactiveDataHelper.ts @@ -1,5 +1,5 @@ import { Tracker } from 'meteor/tracker' -import { meteorSubscribe, PubSubTypes } from '../../../lib/api/pubsub' +import { meteorSubscribe, AllPubSubTypes } from '../../../lib/api/pubsub' import { Meteor } from 'meteor/meteor' /** @@ -70,7 +70,7 @@ export abstract class WithManagedTracker { return this._subs.every((e) => e.ready()) } - protected subscribe(sub: K, ...args: Parameters): void { + protected subscribe(sub: K, ...args: Parameters): void { this._subs.push(meteorSubscribe(sub, ...args)) } diff --git a/meteor/client/lib/triggers/TriggersHandler.tsx b/meteor/client/lib/triggers/TriggersHandler.tsx index ac48e5bc40..de630f935e 100644 --- a/meteor/client/lib/triggers/TriggersHandler.tsx +++ b/meteor/client/lib/triggers/TriggersHandler.tsx @@ -3,7 +3,7 @@ import { useEffect, useRef, useState } from 'react' import { TFunction } from 'i18next' import { useTranslation } from 'react-i18next' import Sorensen from '@sofie-automation/sorensen' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { useSubscription, useTracker } from '../ReactMeteorData/ReactMeteorData' import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' import { PlayoutActions, SomeAction, SomeBlueprintTrigger, TriggerType } from '@sofie-automation/blueprints-integration' @@ -43,6 +43,7 @@ import { isHotkeyTrigger } from '../../../lib/api/triggers/triggerTypeSelectors' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' import { catchError } from '../lib' import { logger } from '../../../lib/logging' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' type HotkeyTriggerListener = (e: KeyboardEvent) => void @@ -72,32 +73,32 @@ function useSubscriptions( showStyleBaseId: ShowStyleBaseId ) { const allReady = [ - useSubscription(PubSub.rundownPlaylists, { + useSubscription(CorelibPubSub.rundownPlaylists, { _id: rundownPlaylistId, }), - useSubscription(PubSub.rundowns, [rundownPlaylistId], null), + useSubscription(CorelibPubSub.rundowns, [rundownPlaylistId], null), - useSubscription(PubSub.adLibActions, { + useSubscription(CorelibPubSub.adLibActions, { rundownId: { $in: rundownIds, }, }), - useSubscription(PubSub.adLibPieces, { + useSubscription(CorelibPubSub.adLibPieces, { rundownId: { $in: rundownIds, }, }), - useSubscription(PubSub.rundownBaselineAdLibActions, { + useSubscription(CorelibPubSub.rundownBaselineAdLibActions, { rundownId: { $in: rundownIds, }, }), - useSubscription(PubSub.rundownBaselineAdLibPieces, { + useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, { rundownId: { $in: rundownIds, }, }), - useSubscription(PubSub.uiShowStyleBase, showStyleBaseId), + useSubscription(MeteorPubSub.uiShowStyleBase, showStyleBaseId), ] return !allReady.some((state) => state === false) @@ -371,7 +372,7 @@ export const TriggersHandler: React.FC = function TriggersHandler( JSON.stringify(props.nextSegmentPartIds), ]) - const triggerSubReady = useSubscription(PubSub.uiTriggeredActions, props.showStyleBaseId) + const triggerSubReady = useSubscription(MeteorPubSub.uiTriggeredActions, props.showStyleBaseId) const rundownIds = useTracker(() => { diff --git a/meteor/client/ui/Account/OrganizationPage.tsx b/meteor/client/ui/Account/OrganizationPage.tsx index 1c263cc071..b00c218b35 100644 --- a/meteor/client/ui/Account/OrganizationPage.tsx +++ b/meteor/client/ui/Account/OrganizationPage.tsx @@ -3,7 +3,7 @@ import { Translated, translateWithTracker } from '../../lib/ReactMeteorData/reac import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { getUser, User, getUserRoles, DBUser } from '../../../lib/collections/Users' import { Spinner } from '../../lib/Spinner' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { DBOrganization, UserRoles } from '../../../lib/collections/Organization' import { unprotectString } from '../../../lib/lib' import { MeteorCall } from '../../../lib/api/methods' @@ -53,7 +53,7 @@ export const OrganizationPage = translateWithTracker(() => { componentDidMount(): void { this.autorun(() => { if (this.props.organization) { - this.subscribe(PubSub.usersInOrganization, { organizationId: this.props.organization._id }) + this.subscribe(MeteorPubSub.usersInOrganization, { organizationId: this.props.organization._id }) } }) } diff --git a/meteor/client/ui/ActiveRundownView.tsx b/meteor/client/ui/ActiveRundownView.tsx index 0c269d745a..fcc5785385 100644 --- a/meteor/client/ui/ActiveRundownView.tsx +++ b/meteor/client/ui/ActiveRundownView.tsx @@ -4,19 +4,20 @@ import { useSubscription, useTracker } from '../lib/ReactMeteorData/ReactMeteorD import { Spinner } from '../lib/Spinner' import { RundownView } from './RundownView' -import { PubSub } from '../../lib/api/pubsub' +import { MeteorPubSub } from '../../lib/api/pubsub' import { UIStudios } from './Collections' import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { RundownPlaylists } from '../collections' import { useTranslation } from 'react-i18next' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export function ActiveRundownView({ studioId }: { studioId: StudioId }): JSX.Element | null { const { t } = useTranslation() const { path } = useRouteMatch() - const studioReady = useSubscription(PubSub.uiStudio, studioId) - const playlistReady = useSubscription(PubSub.rundownPlaylists, { + const studioReady = useSubscription(MeteorPubSub.uiStudio, studioId) + const playlistReady = useSubscription(CorelibPubSub.rundownPlaylists, { activationId: { $exists: true }, studioId, }) diff --git a/meteor/client/ui/App.tsx b/meteor/client/ui/App.tsx index 78877a92c8..e101c78d83 100644 --- a/meteor/client/ui/App.tsx +++ b/meteor/client/ui/App.tsx @@ -52,7 +52,7 @@ import { ResetPasswordPage } from './Account/NotLoggedIn/ResetPasswordPage' import { AccountPage } from './Account/AccountPage' import { OrganizationPage } from './Account/OrganizationPage' import { getUser, User } from '../../lib/collections/Users' -import { PubSub } from '../../lib/api/pubsub' +import { MeteorPubSub } from '../../lib/api/pubsub' import { useTracker, useSubscription } from '../lib/ReactMeteorData/ReactMeteorData' import { DocumentTitleProvider } from '../lib/DocumentTitleProvider' import { Spinner } from '../lib/Spinner' @@ -82,8 +82,8 @@ export const App: React.FC = function App() { const [lastStart] = useState(Date.now()) const [requestedRoute, setRequestedRoute] = useState() - const userReady = useSubscription(PubSub.loggedInUser) - const orgReady = useSubscription(PubSub.organization, user?.organizationId ?? null) + const userReady = useSubscription(MeteorPubSub.loggedInUser) + const orgReady = useSubscription(MeteorPubSub.organization, user?.organizationId ?? null) const subsReady = userReady && orgReady diff --git a/meteor/client/ui/ClipTrimPanel/ClipTrimPanel.tsx b/meteor/client/ui/ClipTrimPanel/ClipTrimPanel.tsx index 1ef2eef98a..76fdee741b 100644 --- a/meteor/client/ui/ClipTrimPanel/ClipTrimPanel.tsx +++ b/meteor/client/ui/ClipTrimPanel/ClipTrimPanel.tsx @@ -9,9 +9,9 @@ import { UIStudio } from '../../../lib/api/studios' import { useTranslation } from 'react-i18next' import { useContentStatusForPiece } from '../SegmentTimeline/withMediaObjectStatus' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' -import { PubSub } from '../../../lib/api/pubsub' import { PieceId, RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { Pieces } from '../../collections' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export interface IProps { studio: UIStudio @@ -86,7 +86,7 @@ export function ClipTrimPanel({ }: IProps): JSX.Element { const { t } = useTranslation() - useSubscription(PubSub.pieces, { _id: pieceId, startRundownId: rundownId }) + useSubscription(CorelibPubSub.pieces, { _id: pieceId, startRundownId: rundownId }) const piece = useTracker(() => Pieces.findOne(pieceId), [pieceId]) diff --git a/meteor/client/ui/ClockView/CameraScreen/Rundown.tsx b/meteor/client/ui/ClockView/CameraScreen/Rundown.tsx index 5916e60adc..3325145f04 100644 --- a/meteor/client/ui/ClockView/CameraScreen/Rundown.tsx +++ b/meteor/client/ui/ClockView/CameraScreen/Rundown.tsx @@ -1,7 +1,7 @@ import React, { useContext } from 'react' import { useSubscription, useTracker } from '../../../lib/ReactMeteorData/ReactMeteorData' import { Rundown as RundownObj } from '@sofie-automation/corelib/dist/dataModel/Rundown' -import { PubSub } from '../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../lib/api/pubsub' import { Segments } from '../../../collections' import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment' import { Segment as SegmentComponent } from './Segment' @@ -20,7 +20,7 @@ interface IProps { export function Rundown({ playlist, rundown, rundownIdsBefore }: IProps): JSX.Element | null { const rundownId = rundown._id - useSubscription(PubSub.uiShowStyleBase, rundown.showStyleBaseId) + useSubscription(MeteorPubSub.uiShowStyleBase, rundown.showStyleBaseId) const segments = useTracker(() => Segments.find({ rundownId }).fetch(), [rundownId], [] as DBSegment[]) diff --git a/meteor/client/ui/ClockView/CameraScreen/index.tsx b/meteor/client/ui/ClockView/CameraScreen/index.tsx index 431ab4be7e..9d73e9319d 100644 --- a/meteor/client/ui/ClockView/CameraScreen/index.tsx +++ b/meteor/client/ui/ClockView/CameraScreen/index.tsx @@ -3,7 +3,7 @@ import { CameraContent, RemoteContent, SourceLayerType, SplitsContent } from '@s import { RundownId, ShowStyleBaseId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' import { unprotectString } from '@sofie-automation/corelib/dist/protectedString' -import { PubSub } from '../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../lib/api/pubsub' import { UIStudio } from '../../../../lib/api/studios' import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' import { PieceExtended } from '../../../../lib/Rundown' @@ -21,6 +21,7 @@ import { Spinner } from '../../../lib/Spinner' import { useBlackBrowserTheme } from '../../../lib/useBlackBrowserTheme' import { useWakeLock } from './useWakeLock' import { catchError, useDebounce } from '../../../lib/lib' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IProps { playlist: DBRundownPlaylist | undefined @@ -94,25 +95,25 @@ export function CameraScreen({ playlist, studioId }: IProps): JSX.Element | null const rundownIds = useMemo(() => rundowns.map((rundown) => rundown._id), [rundowns]) const showStyleBaseIds = useMemo(() => rundowns.map((rundown) => rundown.showStyleBaseId), [rundowns]) - const rundownsReady = useSubscription(PubSub.rundowns, playlistIds, null) - useSubscription(PubSub.segments, { + const rundownsReady = useSubscription(CorelibPubSub.rundowns, playlistIds, null) + useSubscription(CorelibPubSub.segments, { rundownId: { $in: rundownIds, }, }) - const studioReady = useSubscription(PubSub.uiStudio, studioId) - useSubscription(PubSub.partInstances, rundownIds, playlist?.activationId) + const studioReady = useSubscription(MeteorPubSub.uiStudio, studioId) + useSubscription(CorelibPubSub.partInstances, rundownIds, playlist?.activationId) - useSubscription(PubSub.parts, rundownIds) + useSubscription(CorelibPubSub.parts, rundownIds) - useSubscription(PubSub.pieceInstancesSimple, { + useSubscription(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: rundownIds, }, }) - const piecesReady = useSubscription(PubSub.pieces, { + const piecesReady = useSubscription(CorelibPubSub.pieces, { startRundownId: { $in: rundownIds, }, diff --git a/meteor/client/ui/ClockView/ClockView.tsx b/meteor/client/ui/ClockView/ClockView.tsx index 70afd06fae..2173c07ac4 100644 --- a/meteor/client/ui/ClockView/ClockView.tsx +++ b/meteor/client/ui/ClockView/ClockView.tsx @@ -4,7 +4,6 @@ import { useSubscription, useTracker } from '../../lib/ReactMeteorData/react-met import { RundownTimingProvider } from '../RundownView/RundownTiming/RundownTimingProvider' -import { PubSub } from '../../../lib/api/pubsub' import { StudioScreenSaver } from '../StudioScreenSaver/StudioScreenSaver' import { PresenterScreen } from './PresenterScreen' import { OverlayScreen } from './OverlayScreen' @@ -12,9 +11,10 @@ import { OverlayScreenSaver } from './OverlayScreenSaver' import { RundownPlaylists } from '../../collections' import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { CameraScreen } from './CameraScreen' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export function ClockView({ studioId }: { studioId: StudioId }): JSX.Element { - useSubscription(PubSub.rundownPlaylists, { + useSubscription(CorelibPubSub.rundownPlaylists, { activationId: { $exists: true }, studioId, }) diff --git a/meteor/client/ui/ClockView/OverlayScreenSaver.tsx b/meteor/client/ui/ClockView/OverlayScreenSaver.tsx index 39b6cf7680..c8bc813118 100644 --- a/meteor/client/ui/ClockView/OverlayScreenSaver.tsx +++ b/meteor/client/ui/ClockView/OverlayScreenSaver.tsx @@ -1,11 +1,12 @@ import React, { useEffect, useRef } from 'react' import { Clock } from '../StudioScreenSaver/Clock' import { useTracker, useSubscription } from '../../lib/ReactMeteorData/ReactMeteorData' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { findNextPlaylist } from '../StudioScreenSaver/StudioScreenSaver' // @ts-expect-error No types available import Velocity from 'velocity-animate' import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export function OverlayScreenSaver({ studioId }: { studioId: StudioId }): JSX.Element { const studioNameRef = useRef(null) @@ -17,8 +18,8 @@ export function OverlayScreenSaver({ studioId }: { studioId: StudioId }): JSX.El } }) - useSubscription(PubSub.uiStudio, studioId) - useSubscription(PubSub.rundownPlaylists, { studioId: studioId, activationId: { $exists: false } }) + useSubscription(MeteorPubSub.uiStudio, studioId) + useSubscription(CorelibPubSub.rundownPlaylists, { studioId: studioId, activationId: { $exists: false } }) const data = useTracker(() => findNextPlaylist({ studioId }), [studioId]) diff --git a/meteor/client/ui/ClockView/PresenterScreen.tsx b/meteor/client/ui/ClockView/PresenterScreen.tsx index 2d507f6b8b..d63a150e18 100644 --- a/meteor/client/ui/ClockView/PresenterScreen.tsx +++ b/meteor/client/ui/ClockView/PresenterScreen.tsx @@ -10,7 +10,7 @@ import { Translated, withTracker } from '../../lib/ReactMeteorData/ReactMeteorDa import { extendMandadory, getCurrentTime, protectString, unprotectString } from '../../../lib/lib' import { PartInstance } from '../../../lib/collections/PartInstances' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { PieceIconContainer } from '../PieceIcons/PieceIcon' import { PieceNameContainer } from '../PieceIcons/PieceName' import { Timediff } from './Timediff' @@ -41,6 +41,7 @@ import { UIStudio } from '../../../lib/api/studios' import { PieceInstances, RundownLayouts, RundownPlaylists, Rundowns, ShowStyleVariants } from '../../collections' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' import { Piece } from '@sofie-automation/corelib/dist/dataModel/Piece' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface SegmentUi extends DBSegment { items: Array @@ -305,7 +306,7 @@ export class PresenterScreenBase extends MeteorReactComponent< protected subscribeToData(): void { this.autorun(() => { - this.subscribe(PubSub.uiStudio, this.props.studioId) + this.subscribe(MeteorPubSub.uiStudio, this.props.studioId) const playlist = RundownPlaylists.findOne(this.props.playlistId, { fields: { @@ -314,7 +315,7 @@ export class PresenterScreenBase extends MeteorReactComponent< }, }) as Pick | undefined if (playlist) { - this.subscribe(PubSub.rundowns, [playlist._id], null) + this.subscribe(CorelibPubSub.rundowns, [playlist._id], null) this.autorun(() => { const rundowns = RundownPlaylistCollectionUtil.getRundownsUnordered(playlist, undefined, { @@ -328,22 +329,22 @@ export class PresenterScreenBase extends MeteorReactComponent< const showStyleBaseIds = rundowns.map((r) => r.showStyleBaseId) const showStyleVariantIds = rundowns.map((r) => r.showStyleVariantId) - this.subscribe(PubSub.segments, { + this.subscribe(CorelibPubSub.segments, { rundownId: { $in: rundownIds }, }) - this.subscribe(PubSub.parts, rundownIds) - this.subscribe(PubSub.partInstances, rundownIds, playlist.activationId) + this.subscribe(CorelibPubSub.parts, rundownIds) + this.subscribe(CorelibPubSub.partInstances, rundownIds, playlist.activationId) for (const rundown of rundowns) { - this.subscribe(PubSub.uiShowStyleBase, rundown.showStyleBaseId) + this.subscribe(MeteorPubSub.uiShowStyleBase, rundown.showStyleBaseId) } - this.subscribe(PubSub.showStyleVariants, { + this.subscribe(CorelibPubSub.showStyleVariants, { _id: { $in: showStyleVariantIds, }, }) - this.subscribe(PubSub.rundownLayouts, { + this.subscribe(MeteorPubSub.rundownLayouts, { showStyleBaseId: { $in: showStyleBaseIds, }, @@ -362,13 +363,13 @@ export class PresenterScreenBase extends MeteorReactComponent< const { nextPartInstance, currentPartInstance } = RundownPlaylistCollectionUtil.getSelectedPartInstances(playlistR) if (currentPartInstance) { - this.subscribe(PubSub.pieceInstances, { + this.subscribe(CorelibPubSub.pieceInstances, { rundownId: currentPartInstance.rundownId, partInstanceId: currentPartInstance._id, }) } if (nextPartInstance) { - this.subscribe(PubSub.pieceInstances, { + this.subscribe(CorelibPubSub.pieceInstances, { rundownId: nextPartInstance.rundownId, partInstanceId: nextPartInstance._id, }) diff --git a/meteor/client/ui/MediaStatus/MediaStatus.tsx b/meteor/client/ui/MediaStatus/MediaStatus.tsx index 42f3b250a7..298bb0f8c8 100644 --- a/meteor/client/ui/MediaStatus/MediaStatus.tsx +++ b/meteor/client/ui/MediaStatus/MediaStatus.tsx @@ -1,6 +1,6 @@ import { useMemo, JSX } from 'react' import { useSubscription, useSubscriptions, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { getSegmentsWithPartInstances } from '../../../lib/Rundown' import { AdLibActionId, @@ -35,6 +35,7 @@ import { assertNever, literal } from '@sofie-automation/corelib/dist/lib' import { UIPieceContentStatuses, UIShowStyleBases } from '../Collections' import { isTranslatableMessage, translateMessage } from '@sofie-automation/corelib/dist/TranslatableMessage' import { i18nTranslator } from '../i18n' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export function MediaStatus({ playlistIds, @@ -256,24 +257,24 @@ function useMediaStatusSubscriptions( ): boolean { const readyStatus: boolean[] = [] let counter = 0 - readyStatus[counter++] = useSubscription(PubSub.rundownPlaylists, { + readyStatus[counter++] = useSubscription(CorelibPubSub.rundownPlaylists, { _id: { $in: playlistIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.rundowns, playlistIds, null) + readyStatus[counter++] = useSubscription(CorelibPubSub.rundowns, playlistIds, null) const uiShowStyleBaseSubArguments = useMemo( () => showStyleBaseIds.map((showStyleBaseId) => [showStyleBaseId] as [ShowStyleBaseId]), [showStyleBaseIds] ) - readyStatus[counter++] = useSubscriptions(PubSub.uiShowStyleBase, uiShowStyleBaseSubArguments) - readyStatus[counter++] = useSubscription(PubSub.segments, { + readyStatus[counter++] = useSubscriptions(MeteorPubSub.uiShowStyleBase, uiShowStyleBaseSubArguments) + readyStatus[counter++] = useSubscription(CorelibPubSub.segments, { rundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.parts, rundownIds) - readyStatus[counter++] = useSubscription(PubSub.partInstancesSimple, { + readyStatus[counter++] = useSubscription(CorelibPubSub.parts, rundownIds) + readyStatus[counter++] = useSubscription(CorelibPubSub.partInstancesSimple, { rundownId: { $in: rundownIds, }, @@ -281,32 +282,32 @@ function useMediaStatusSubscriptions( $ne: true, }, }) - readyStatus[counter++] = useSubscription(PubSub.pieceInstancesSimple, { + readyStatus[counter++] = useSubscription(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.pieces, { + readyStatus[counter++] = useSubscription(CorelibPubSub.pieces, { startRundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.adLibActions, { + readyStatus[counter++] = useSubscription(CorelibPubSub.adLibActions, { rundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.adLibPieces, { + readyStatus[counter++] = useSubscription(CorelibPubSub.adLibPieces, { rundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.rundownBaselineAdLibActions, { + readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibActions, { rundownId: { $in: rundownIds, }, }) - readyStatus[counter++] = useSubscription(PubSub.rundownBaselineAdLibPieces, { + readyStatus[counter++] = useSubscription(CorelibPubSub.rundownBaselineAdLibPieces, { rundownId: { $in: rundownIds, }, @@ -315,7 +316,7 @@ function useMediaStatusSubscriptions( () => playlistIds.map((playlistIds) => [playlistIds] as [RundownPlaylistId]), [playlistIds] ) - readyStatus[counter++] = useSubscriptions(PubSub.uiPieceContentStatuses, uiPieceContentStatusesSubArguments) + readyStatus[counter++] = useSubscriptions(MeteorPubSub.uiPieceContentStatuses, uiPieceContentStatusesSubArguments) return readyStatus.reduce((mem, current) => mem && current, true) } diff --git a/meteor/client/ui/PieceIcons/PieceCountdown.tsx b/meteor/client/ui/PieceIcons/PieceCountdown.tsx index 94c0d0c1fd..2a59e7dfa2 100644 --- a/meteor/client/ui/PieceIcons/PieceCountdown.tsx +++ b/meteor/client/ui/PieceIcons/PieceCountdown.tsx @@ -1,7 +1,7 @@ import React from 'react' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' import { SourceLayerType, VTContent } from '@sofie-automation/blueprints-integration' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { findPieceInstanceToShow } from './utils' import { Timediff } from '../ClockView/Timediff' import { getCurrentTime } from '../../../lib/lib' @@ -11,6 +11,7 @@ import { RundownPlaylistActivationId, ShowStyleBaseId, } from '@sofie-automation/corelib/dist/dataModel/Ids' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export interface IPropsHeader { partInstanceId: PartInstanceId @@ -41,12 +42,12 @@ export function PieceCountdownContainer(props: IPropsHeader): JSX.Element | null } ) - useSubscription(PubSub.pieceInstancesSimple, { + useSubscription(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: props.rundownIds }, playlistActivationId: props.playlistActivationId, }) - useSubscription(PubSub.uiShowStyleBase, props.showStyleBaseId) + useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId) const piece = pieceInstance ? pieceInstance.piece : undefined const sourceDuration = (piece?.content as VTContent)?.sourceDuration diff --git a/meteor/client/ui/PieceIcons/PieceIcon.tsx b/meteor/client/ui/PieceIcons/PieceIcon.tsx index 0ada6d4793..b6e017c0f8 100644 --- a/meteor/client/ui/PieceIcons/PieceIcon.tsx +++ b/meteor/client/ui/PieceIcons/PieceIcon.tsx @@ -14,7 +14,7 @@ import RemoteInputIcon from './Renderers/RemoteInputIcon' import LiveSpeakInputIcon from './Renderers/LiveSpeakInputIcon' import GraphicsInputIcon from './Renderers/GraphicsInputIcon' import UnknownInputIcon from './Renderers/UnknownInputIcon' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { PieceInstance } from '@sofie-automation/corelib/dist/dataModel/PieceInstance' import { findPieceInstanceToShow, findPieceInstanceToShowFromInstances } from './utils' import LocalInputIcon from './Renderers/LocalInputIcon' @@ -25,6 +25,7 @@ import { ShowStyleBaseId, } from '@sofie-automation/corelib/dist/dataModel/Ids' import { ReadonlyDeep } from 'type-fest' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export interface IPropsHeader { partInstanceId: PartInstanceId @@ -129,12 +130,12 @@ export function PieceIconContainer(props: IPropsHeader): JSX.Element | null { } ) - useSubscription(PubSub.pieceInstancesSimple, { + useSubscription(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: props.rundownIds }, playlistActivationId: props.playlistActivationId, }) - useSubscription(PubSub.uiShowStyleBase, props.showStyleBaseId) + useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId) return } diff --git a/meteor/client/ui/PieceIcons/PieceName.tsx b/meteor/client/ui/PieceIcons/PieceName.tsx index 30acdeed39..c8ace6b1bb 100644 --- a/meteor/client/ui/PieceIcons/PieceName.tsx +++ b/meteor/client/ui/PieceIcons/PieceName.tsx @@ -2,12 +2,13 @@ import React from 'react' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' import { EvsContent, SourceLayerType } from '@sofie-automation/blueprints-integration' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { IPropsHeader } from './PieceIcon' import { findPieceInstanceToShow } from './utils' import { PieceGeneric } from '@sofie-automation/corelib/dist/dataModel/Piece' import { RundownPlaylistActivationId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { ReadonlyDeep } from 'type-fest' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface INamePropsHeader extends IPropsHeader { partName: string @@ -54,12 +55,12 @@ export function PieceNameContainer(props: INamePropsHeader): JSX.Element | null } ) - useSubscription(PubSub.pieceInstancesSimple, { + useSubscription(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: props.rundownIds }, playlistActivationId: props.playlistActivationId, }) - useSubscription(PubSub.uiShowStyleBase, props.showStyleBaseId) + useSubscription(MeteorPubSub.uiShowStyleBase, props.showStyleBaseId) if (pieceInstance && sourceLayer && supportedLayers.has(sourceLayer.type)) { return getPieceLabel(pieceInstance.piece, sourceLayer.type) diff --git a/meteor/client/ui/Prompter/PrompterView.tsx b/meteor/client/ui/Prompter/PrompterView.tsx index d7969babe0..7ecffa7721 100644 --- a/meteor/client/ui/Prompter/PrompterView.tsx +++ b/meteor/client/ui/Prompter/PrompterView.tsx @@ -14,7 +14,7 @@ import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { firstIfArray, literal, protectString } from '../../../lib/lib' import { PrompterData, PrompterAPI, PrompterDataPart } from './prompter' import { PrompterControlManager } from './controller/manager' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { documentTitle } from '../../lib/DocumentTitleProvider' import { StudioScreenSaver } from '../StudioScreenSaver/StudioScreenSaver' import { RundownTimingProvider } from '../RundownView/RundownTiming/RundownTimingProvider' @@ -26,6 +26,7 @@ import { UIStudio } from '../../../lib/api/studios' import { RundownPlaylists, Rundowns } from '../../collections' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' import { logger } from '../../../lib/logging' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' const DEFAULT_UPDATE_THROTTLE = 250 //ms const PIECE_MISSING_UPDATE_THROTTLE = 2000 //ms @@ -203,9 +204,9 @@ export class PrompterViewInner extends MeteorReactComponent | undefined if (playlist?._id) { - this.subscribe(PubSub.rundowns, [playlist._id], null) + this.subscribe(CorelibPubSub.rundowns, [playlist._id], null) } }) @@ -598,7 +599,7 @@ export const Prompter = translateWithTracker, } componentDidMount(): void { - this.subscribe(PubSub.rundowns, [this.props.rundownPlaylistId], null) + this.subscribe(CorelibPubSub.rundowns, [this.props.rundownPlaylistId], null) this.autorun(() => { const playlist = RundownPlaylists.findOne(this.props.rundownPlaylistId, { @@ -609,15 +610,15 @@ export const Prompter = translateWithTracker, }) as Pick | undefined if (playlist) { const rundownIDs = RundownPlaylistCollectionUtil.getRundownUnorderedIDs(playlist) - this.subscribe(PubSub.segments, { + this.subscribe(CorelibPubSub.segments, { rundownId: { $in: rundownIDs }, }) - this.subscribe(PubSub.parts, rundownIDs) - this.subscribe(PubSub.partInstances, rundownIDs, playlist.activationId) - this.subscribe(PubSub.pieces, { + this.subscribe(CorelibPubSub.parts, rundownIDs) + this.subscribe(CorelibPubSub.partInstances, rundownIDs, playlist.activationId) + this.subscribe(CorelibPubSub.pieces, { startRundownId: { $in: rundownIDs }, }) - this.subscribe(PubSub.pieceInstancesSimple, { + this.subscribe(CorelibPubSub.pieceInstancesSimple, { rundownId: { $in: rundownIDs }, reset: { $ne: true }, }) @@ -635,7 +636,7 @@ export const Prompter = translateWithTracker, } ).fetch() as Pick[] for (const rundown of rundowns) { - this.subscribe(PubSub.uiShowStyleBase, rundown.showStyleBaseId) + this.subscribe(MeteorPubSub.uiShowStyleBase, rundown.showStyleBaseId) } }) } diff --git a/meteor/client/ui/RundownList.tsx b/meteor/client/ui/RundownList.tsx index 27571d3d06..2c33d7de25 100644 --- a/meteor/client/ui/RundownList.tsx +++ b/meteor/client/ui/RundownList.tsx @@ -1,6 +1,6 @@ import Tooltip from 'rc-tooltip' import * as React from 'react' -import { PubSub } from '../../lib/api/pubsub' +import { MeteorPubSub } from '../../lib/api/pubsub' import { GENESIS_SYSTEM_VERSION } from '../../lib/collections/CoreSystem' import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' import { getAllowConfigure, getHelpMode } from '../lib/localStorage' @@ -19,6 +19,7 @@ import { getCoreSystem, RundownLayouts, RundownPlaylists, Rundowns } from '../co import { RundownPlaylistCollectionUtil } from '../../lib/collections/rundownPlaylistUtil' import { useEffect, useMemo, useState } from 'react' import { useTranslation } from 'react-i18next' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export enum ToolTipStep { TOOLTIP_START_HERE = 'TOOLTIP_START_HERE', @@ -59,17 +60,17 @@ export function RundownList(): JSX.Element { ) const baseSubsReady = [ - useSubscription(PubSub.rundownPlaylists, {}), - useSubscription(PubSub.uiStudio, null), - useSubscription(PubSub.rundownLayouts, {}), + useSubscription(CorelibPubSub.rundownPlaylists, {}), + useSubscription(MeteorPubSub.uiStudio, null), + useSubscription(MeteorPubSub.rundownLayouts, {}), - useSubscription(PubSub.rundowns, playlistIds, null), + useSubscription(CorelibPubSub.rundowns, playlistIds, null), - useSubscription(PubSub.showStyleBases, { + useSubscription(CorelibPubSub.showStyleBases, { _id: { $in: showStyleBaseIds }, }), - useSubscription(PubSub.showStyleVariants, { + useSubscription(CorelibPubSub.showStyleVariants, { _id: { $in: showStyleVariantIds }, }), ].reduce((prev, current) => prev && current, true) diff --git a/meteor/client/ui/RundownView.tsx b/meteor/client/ui/RundownView.tsx index 12fa41923c..c8affdb093 100644 --- a/meteor/client/ui/RundownView.tsx +++ b/meteor/client/ui/RundownView.tsx @@ -63,7 +63,7 @@ import { PeripheralDevice, PeripheralDeviceType } from '@sofie-automation/coreli import { doUserAction, UserAction } from '../../lib/clientUserAction' import { hashSingleUseToken, ReloadRundownPlaylistResponse, TriggerReloadDataResponse } from '../../lib/api/userActions' import { ClipTrimDialog } from './ClipTrimPanel/ClipTrimDialog' -import { meteorSubscribe, PubSub } from '../../lib/api/pubsub' +import { meteorSubscribe, MeteorPubSub } from '../../lib/api/pubsub' import { RundownLayoutType, RundownLayoutBase, @@ -148,6 +148,7 @@ import { PromiseButton } from '../lib/Components/PromiseButton' import { logger } from '../../lib/logging' import { isTranslatableMessage, translateMessage } from '@sofie-automation/corelib/dist/TranslatableMessage' import { i18nTranslator } from './i18n' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export const MAGIC_TIME_SCALE_FACTOR = 0.03 @@ -1578,10 +1579,10 @@ export const RundownView = translateWithTracker(( componentDidMount(): void { const playlistId = this.props.rundownPlaylistId - this.subscribe(PubSub.rundownPlaylists, { + this.subscribe(CorelibPubSub.rundownPlaylists, { _id: playlistId, }) - this.subscribe(PubSub.rundowns, [playlistId], null) + this.subscribe(CorelibPubSub.rundowns, [playlistId], null) this.autorun(() => { const playlist = RundownPlaylists.findOne(playlistId, { fields: { @@ -1591,10 +1592,10 @@ export const RundownView = translateWithTracker(( }) as Pick | undefined if (!playlist) return - this.subscribe(PubSub.uiSegmentPartNotes, playlistId) - this.subscribe(PubSub.uiPieceContentStatuses, playlistId) - this.subscribe(PubSub.uiStudio, playlist.studioId) - this.subscribe(PubSub.buckets, playlist.studioId, null) + this.subscribe(MeteorPubSub.uiSegmentPartNotes, playlistId) + this.subscribe(MeteorPubSub.uiPieceContentStatuses, playlistId) + this.subscribe(MeteorPubSub.uiStudio, playlist.studioId) + this.subscribe(MeteorPubSub.buckets, playlist.studioId, null) }) this.autorun(() => { @@ -1615,47 +1616,47 @@ export const RundownView = translateWithTracker(( }) as Pick[] for (const rundown of rundowns) { - this.subscribe(PubSub.uiShowStyleBase, rundown.showStyleBaseId) + this.subscribe(MeteorPubSub.uiShowStyleBase, rundown.showStyleBaseId) } - this.subscribe(PubSub.showStyleVariants, { + this.subscribe(CorelibPubSub.showStyleVariants, { _id: { $in: rundowns.map((i) => i.showStyleVariantId), }, }) - this.subscribe(PubSub.rundownLayouts, { + this.subscribe(MeteorPubSub.rundownLayouts, { showStyleBaseId: { $in: rundowns.map((i) => i.showStyleBaseId), }, }) const rundownIDs = rundowns.map((i) => i._id) - this.subscribe(PubSub.segments, { + this.subscribe(CorelibPubSub.segments, { rundownId: { $in: rundownIDs, }, }) - this.subscribe(PubSub.adLibPieces, { + this.subscribe(CorelibPubSub.adLibPieces, { rundownId: { $in: rundownIDs, }, }) - this.subscribe(PubSub.rundownBaselineAdLibPieces, { + this.subscribe(CorelibPubSub.rundownBaselineAdLibPieces, { rundownId: { $in: rundownIDs, }, }) - this.subscribe(PubSub.adLibActions, { + this.subscribe(CorelibPubSub.adLibActions, { rundownId: { $in: rundownIDs, }, }) - this.subscribe(PubSub.rundownBaselineAdLibActions, { + this.subscribe(CorelibPubSub.rundownBaselineAdLibActions, { rundownId: { $in: rundownIDs, }, }) - this.subscribe(PubSub.parts, rundownIDs) - this.subscribe(PubSub.partInstances, rundownIDs, playlist.activationId) + this.subscribe(CorelibPubSub.parts, rundownIDs) + this.subscribe(CorelibPubSub.partInstances, rundownIDs, playlist.activationId) }) this.autorun(() => { const playlist = RundownPlaylists.findOne(playlistId, { @@ -1670,7 +1671,7 @@ export const RundownView = translateWithTracker(( // Use meteorSubscribe so that this subscription doesn't mess with this.subscriptionsReady() // it's run in this.autorun, so the subscription will be stopped along with the autorun, // so we don't have to manually clean up after ourselves. - meteorSubscribe(PubSub.pieceInstances, { + meteorSubscribe(CorelibPubSub.pieceInstances, { rundownId: { $in: rundownIds, }, @@ -1689,13 +1690,13 @@ export const RundownView = translateWithTracker(( RundownPlaylistCollectionUtil.getSelectedPartInstances(playlist) if (previousPartInstance) { - meteorSubscribe(PubSub.partInstancesForSegmentPlayout, { + meteorSubscribe(CorelibPubSub.partInstancesForSegmentPlayout, { rundownId: previousPartInstance.rundownId, segmentPlayoutId: previousPartInstance.segmentPlayoutId, }) } if (currentPartInstance) { - meteorSubscribe(PubSub.partInstancesForSegmentPlayout, { + meteorSubscribe(CorelibPubSub.partInstancesForSegmentPlayout, { rundownId: currentPartInstance.rundownId, segmentPlayoutId: currentPartInstance.segmentPlayoutId, }) diff --git a/meteor/client/ui/RundownView/RundownNotifier.tsx b/meteor/client/ui/RundownView/RundownNotifier.tsx index 1defeb10e9..6a58df9995 100644 --- a/meteor/client/ui/RundownView/RundownNotifier.tsx +++ b/meteor/client/ui/RundownView/RundownNotifier.tsx @@ -14,7 +14,7 @@ import { WithManagedTracker } from '../../lib/reactiveData/reactiveDataHelper' import { reactiveData } from '../../lib/reactiveData/reactiveData' import { PeripheralDevice } from '@sofie-automation/corelib/dist/dataModel/PeripheralDevice' import { getCurrentTime, unprotectString } from '../../../lib/lib' -import { PubSub, meteorSubscribe } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { ReactiveVar } from 'meteor/reactive-var' import { Rundown } from '@sofie-automation/corelib/dist/dataModel/Rundown' import { doModalDialog } from '../../lib/ModalDialog' @@ -44,6 +44,7 @@ import { import { UIPieceContentStatuses, UISegmentPartNotes } from '../Collections' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' import { logger } from '../../../lib/logging' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export const onRONotificationClick = new ReactiveVar<((e: RONotificationEvent) => void) | undefined>(undefined) export const reloadRundownPlaylistClick = new ReactiveVar<((e: any) => void) | undefined>(undefined) @@ -292,7 +293,7 @@ class RundownViewNotifier extends WithManagedTracker { | ReactiveVar[]> | undefined if (studioId) { - meteorSubscribe(PubSub.peripheralDevicesAndSubDevices, { studioId: studioId }) + meteorSubscribe(CorelibPubSub.peripheralDevicesAndSubDevices, { studioId: studioId }) reactivePeripheralDevices = reactiveData.getRPeripheralDevices(studioId, { fields: { name: 1, @@ -576,7 +577,7 @@ class RundownViewNotifier extends WithManagedTracker { } private reactiveQueueStatus(studioId: StudioId, playlistId: RundownPlaylistId) { - meteorSubscribe(PubSub.externalMessageQueue, { studioId: studioId, playlistId }) + meteorSubscribe(CorelibPubSub.externalMessageQueue, { studioId: studioId, playlistId }) const reactiveUnsentMessageCount = reactiveData.getUnsentExternalMessageCount(studioId, playlistId) this.autorun(() => { if (reactiveUnsentMessageCount.get() > 0 && this._unsentExternalMessagesStatus === undefined) { diff --git a/meteor/client/ui/RundownView/RundownSystemStatus.tsx b/meteor/client/ui/RundownView/RundownSystemStatus.tsx index c975f1f078..43185fb373 100644 --- a/meteor/client/ui/RundownView/RundownSystemStatus.tsx +++ b/meteor/client/ui/RundownView/RundownSystemStatus.tsx @@ -13,11 +13,11 @@ import { Time, getCurrentTime, unprotectString } from '../../../lib/lib' import { withTranslation, WithTranslation } from 'react-i18next' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { DBRundownPlaylist } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist' -import { PubSub } from '../../../lib/api/pubsub' import { StatusCode } from '@sofie-automation/blueprints-integration' import { UIStudio } from '../../../lib/api/studios' import { RundownId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { PeripheralDevices } from '../../collections' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IMOSStatusProps { lastUpdate: Time @@ -180,7 +180,7 @@ export const RundownSystemStatus = translateWithTracker( } componentDidMount(): void { - this.subscribe(PubSub.peripheralDevicesAndSubDevices, { + this.subscribe(CorelibPubSub.peripheralDevicesAndSubDevices, { studioId: this.props.studio._id, }) } diff --git a/meteor/client/ui/SegmentList/LinePartPieceIndicator/LinePartAdLibIndicator.tsx b/meteor/client/ui/SegmentList/LinePartPieceIndicator/LinePartAdLibIndicator.tsx index 8d2b27f386..9601340e09 100644 --- a/meteor/client/ui/SegmentList/LinePartPieceIndicator/LinePartAdLibIndicator.tsx +++ b/meteor/client/ui/SegmentList/LinePartPieceIndicator/LinePartAdLibIndicator.tsx @@ -1,5 +1,4 @@ import React, { useCallback, useMemo } from 'react' -import { PubSub } from '../../../../lib/api/pubsub' import { PartId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { AdLibAction } from '@sofie-automation/corelib/dist/dataModel/AdlibAction' import { AdLibPiece } from '@sofie-automation/corelib/dist/dataModel/AdLibPiece' @@ -11,6 +10,7 @@ import { translateMessage } from '@sofie-automation/corelib/dist/TranslatableMes import StudioContext from '../../RundownView/StudioContext' import { AdLibActions, AdLibPieces } from '../../../collections' import RundownViewEventBus, { RundownViewEvents } from '../../../../lib/api/triggers/RundownViewEventBus' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IProps { sourceLayers: ISourceLayerExtended[] @@ -24,14 +24,14 @@ export const LinePartAdLibIndicator: React.FC = function LinePartAdLibIn const sourceLayerIds = useMemo(() => sourceLayers.map((sourceLayer) => sourceLayer._id), [sourceLayers]) const label = useMemo(() => sourceLayers[0]?.name ?? '', [sourceLayers]) - useSubscription(PubSub.adLibPieces, { + useSubscription(CorelibPubSub.adLibPieces, { partId, sourceLayerId: { $in: sourceLayerIds, }, }) - useSubscription(PubSub.adLibActions, { + useSubscription(CorelibPubSub.adLibActions, { partId, 'display.sourceLayerId': { $in: sourceLayerIds, diff --git a/meteor/client/ui/SegmentList/SegmentListContainer.tsx b/meteor/client/ui/SegmentList/SegmentListContainer.tsx index 7e9509abd8..5e9b1b22d4 100644 --- a/meteor/client/ui/SegmentList/SegmentListContainer.tsx +++ b/meteor/client/ui/SegmentList/SegmentListContainer.tsx @@ -1,6 +1,6 @@ import React, { useEffect, useRef } from 'react' import { PieceLifespan } from '@sofie-automation/blueprints-integration' -import { PubSub, meteorSubscribe } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' import { withResolvedSegment, @@ -12,6 +12,7 @@ import { SegmentList } from './SegmentList' import { unprotectString } from '../../../lib/lib' import { LIVELINE_HISTORY_SIZE as TIMELINE_LIVELINE_HISTORY_SIZE } from '../SegmentTimeline/SegmentTimelineContainer' import { PartInstances, Parts, Segments } from '../../collections' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export const LIVELINE_HISTORY_SIZE = TIMELINE_LIVELINE_HISTORY_SIZE @@ -41,7 +42,7 @@ export const SegmentListContainer = withResolvedSegment(function Segment [segmentId] ) - useSubscription(PubSub.pieces, { + useSubscription(CorelibPubSub.pieces, { startRundownId: rundownId, startPartId: { $in: partIds, @@ -67,7 +68,7 @@ export const SegmentListContainer = withResolvedSegment(function Segment [segmentId] ) - useSubscription(PubSub.pieceInstances, { + useSubscription(CorelibPubSub.pieceInstances, { rundownId: rundownId, partInstanceId: { $in: partInstanceIds, @@ -85,7 +86,7 @@ export const SegmentListContainer = withResolvedSegment(function Segment }, }) segment && - meteorSubscribe(PubSub.pieces, { + meteorSubscribe(CorelibPubSub.pieces, { invalid: { $ne: true, }, diff --git a/meteor/client/ui/SegmentScratchpad/SegmentScratchpadContainer.tsx b/meteor/client/ui/SegmentScratchpad/SegmentScratchpadContainer.tsx index 7074116dcc..26f0da062f 100644 --- a/meteor/client/ui/SegmentScratchpad/SegmentScratchpadContainer.tsx +++ b/meteor/client/ui/SegmentScratchpad/SegmentScratchpadContainer.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react' import { PieceLifespan } from '@sofie-automation/blueprints-integration' -import { meteorSubscribe, PubSub } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' import { // PartUi, @@ -16,6 +16,7 @@ import { PartInstances, Parts, Segments } from '../../collections' import { literal } from '@sofie-automation/shared-lib/dist/lib/lib' import { MongoFieldSpecifierOnes } from '@sofie-automation/corelib/dist/mongo' import { PartInstance } from '../../../lib/collections/PartInstances' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export const LIVELINE_HISTORY_SIZE = TIMELINE_LIVELINE_HISTORY_SIZE @@ -45,7 +46,7 @@ export const SegmentScratchpadContainer = withResolvedSegment(function S [segmentId] ) - const piecesReady = useSubscription(PubSub.pieces, { + const piecesReady = useSubscription(CorelibPubSub.pieces, { startRundownId: rundownId, startPartId: { $in: partIds, @@ -71,7 +72,7 @@ export const SegmentScratchpadContainer = withResolvedSegment(function S [segmentId] ) - const pieceInstancesReady = useSubscription(PubSub.pieceInstances, { + const pieceInstancesReady = useSubscription(CorelibPubSub.pieceInstances, { rundownId: rundownId, partInstanceId: { $in: partInstanceIds, @@ -89,7 +90,7 @@ export const SegmentScratchpadContainer = withResolvedSegment(function S }, }) segment && - meteorSubscribe(PubSub.pieces, { + meteorSubscribe(CorelibPubSub.pieces, { invalid: { $ne: true, }, diff --git a/meteor/client/ui/SegmentStoryboard/SegmentStoryboardContainer.tsx b/meteor/client/ui/SegmentStoryboard/SegmentStoryboardContainer.tsx index f722285a09..ced92a4863 100644 --- a/meteor/client/ui/SegmentStoryboard/SegmentStoryboardContainer.tsx +++ b/meteor/client/ui/SegmentStoryboard/SegmentStoryboardContainer.tsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useRef, useState } from 'react' import { PieceLifespan } from '@sofie-automation/blueprints-integration' -import { meteorSubscribe, PubSub } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { useSubscription, useTracker } from '../../lib/ReactMeteorData/ReactMeteorData' import { // PartUi, @@ -16,6 +16,7 @@ import { PartInstances, Parts, Segments } from '../../collections' import { literal } from '@sofie-automation/shared-lib/dist/lib/lib' import { MongoFieldSpecifierOnes } from '@sofie-automation/corelib/dist/mongo' import { PartInstance } from '../../../lib/collections/PartInstances' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export const LIVELINE_HISTORY_SIZE = TIMELINE_LIVELINE_HISTORY_SIZE @@ -45,7 +46,7 @@ export const SegmentStoryboardContainer = withResolvedSegment(function S [segmentId] ) - const piecesReady = useSubscription(PubSub.pieces, { + const piecesReady = useSubscription(CorelibPubSub.pieces, { startRundownId: rundownId, startPartId: { $in: partIds, @@ -71,7 +72,7 @@ export const SegmentStoryboardContainer = withResolvedSegment(function S [segmentId] ) - const pieceInstancesReady = useSubscription(PubSub.pieceInstances, { + const pieceInstancesReady = useSubscription(CorelibPubSub.pieceInstances, { rundownId: rundownId, partInstanceId: { $in: partInstanceIds, @@ -89,7 +90,7 @@ export const SegmentStoryboardContainer = withResolvedSegment(function S }, }) segment && - meteorSubscribe(PubSub.pieces, { + meteorSubscribe(CorelibPubSub.pieces, { invalid: { $ne: true, }, diff --git a/meteor/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx b/meteor/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx index e32f46601c..e9ae6d6a2d 100644 --- a/meteor/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx +++ b/meteor/client/ui/SegmentTimeline/SegmentTimelineContainer.tsx @@ -11,7 +11,7 @@ import { MAGIC_TIME_SCALE_FACTOR } from '../RundownView' import { SpeechSynthesiser } from '../../lib/speechSynthesis' import { getElementWidth } from '../../utils/dimensions' import { isMaintainingFocus, scrollToSegment, getHeaderHeight } from '../../lib/viewPort' -import { meteorSubscribe, PubSub } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { unprotectString, equalSets, equivalentArrays } from '../../../lib/lib' import { Settings } from '../../../lib/Settings' import { Tracker } from 'meteor/tracker' @@ -34,6 +34,7 @@ import { RundownViewShelf } from '../RundownView/RundownViewShelf' import { PartInstanceId, SegmentId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { PartInstances, Parts, Segments } from '../../collections' import { catchError } from '../../lib/lib' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' // Kept for backwards compatibility export { SegmentUi, PartUi, PieceUi, ISourceLayerUi, IOutputLayerUi } from '../SegmentContainer/withResolvedSegment' @@ -145,7 +146,7 @@ export const SegmentTimelineContainer = withResolvedSegment( } ).map((part) => part._id) - this.subscribe(PubSub.pieces, { + this.subscribe(CorelibPubSub.pieces, { startRundownId: this.props.rundownId, startPartId: { $in: partIds, @@ -178,7 +179,7 @@ export const SegmentTimelineContainer = withResolvedSegment( }, }) segment && - this.subscribe(PubSub.pieces, { + this.subscribe(CorelibPubSub.pieces, { invalid: { $ne: true, }, @@ -423,7 +424,7 @@ export const SegmentTimelineContainer = withResolvedSegment( this.partInstanceSub.stop() } // we handle this subscription manually - this.partInstanceSub = meteorSubscribe(PubSub.pieceInstances, { + this.partInstanceSub = meteorSubscribe(CorelibPubSub.pieceInstances, { rundownId: this.props.rundownId, partInstanceId: { $in: partInstanceIds, diff --git a/meteor/client/ui/Settings.tsx b/meteor/client/ui/Settings.tsx index b770d93b58..15f553ef8d 100644 --- a/meteor/client/ui/Settings.tsx +++ b/meteor/client/ui/Settings.tsx @@ -11,23 +11,23 @@ import BlueprintSettings from './Settings/BlueprintSettings' import SystemManagement from './Settings/SystemManagement' import { MigrationView } from './Settings/Migration' -import { PubSub } from '../../lib/api/pubsub' import { getUser } from '../../lib/collections/Users' import { Settings as MeteorSettings } from '../../lib/Settings' import { SettingsMenu } from './Settings/SettingsMenu' import { getAllowConfigure } from '../lib/localStorage' import { protectString } from '@sofie-automation/corelib/dist/protectedString' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export function Settings(): JSX.Element | null { const user = useTracker(() => getUser(), [], null) const history = useHistory() - useSubscription(PubSub.peripheralDevices, {}) - useSubscription(PubSub.studios, {}) - useSubscription(PubSub.showStyleBases, {}) - useSubscription(PubSub.showStyleVariants, {}) - useSubscription(PubSub.blueprints, {}) + useSubscription(CorelibPubSub.peripheralDevices, {}) + useSubscription(CorelibPubSub.studios, {}) + useSubscription(CorelibPubSub.showStyleBases, {}) + useSubscription(CorelibPubSub.showStyleVariants, {}) + useSubscription(CorelibPubSub.blueprints, {}) useEffect(() => { if (MeteorSettings.enableUserAccounts && user) { diff --git a/meteor/client/ui/Settings/RundownLayoutEditor.tsx b/meteor/client/ui/Settings/RundownLayoutEditor.tsx index 4d1aa21eb2..fbabfe9c30 100644 --- a/meteor/client/ui/Settings/RundownLayoutEditor.tsx +++ b/meteor/client/ui/Settings/RundownLayoutEditor.tsx @@ -20,7 +20,7 @@ import { CustomizableRegionSettingsManifest, RundownLayoutsAPI, } from '../../../lib/api/rundownLayouts' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { getRandomString, literal, unprotectString } from '../../../lib/lib' import { UploadButton } from '../../lib/uploadButton' import { doModalDialog } from '../../lib/ModalDialog' @@ -83,7 +83,7 @@ export default translateWithTracker((props: IProp componentDidMount(): void { super.componentDidMount && super.componentDidMount() - this.subscribe(PubSub.rundownLayouts, {}) + this.subscribe(MeteorPubSub.rundownLayouts, {}) } onAddLayout = () => { diff --git a/meteor/client/ui/Settings/SettingsMenu.tsx b/meteor/client/ui/Settings/SettingsMenu.tsx index d6a8f13bf7..6f494e1a31 100644 --- a/meteor/client/ui/Settings/SettingsMenu.tsx +++ b/meteor/client/ui/Settings/SettingsMenu.tsx @@ -14,7 +14,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { DBShowStyleBase } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase' import { Blueprint } from '@sofie-automation/corelib/dist/dataModel/Blueprint' -import { PubSub, meteorSubscribe } from '../../../lib/api/pubsub' +import { meteorSubscribe } from '../../../lib/api/pubsub' import { MeteorCall } from '../../../lib/api/methods' import { Settings as MeteorSettings } from '../../../lib/Settings' import { IOutputLayer, StatusCode } from '@sofie-automation/blueprints-integration' @@ -23,6 +23,7 @@ import { RundownLayoutsAPI } from '../../../lib/api/rundownLayouts' import { Blueprints, PeripheralDevices, ShowStyleBases, Studios } from '../../collections' import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides' import { catchError } from '../../lib/lib' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface ISettingsMenuProps { superAdmin?: boolean @@ -38,11 +39,11 @@ export const SettingsMenu = translateWithTracker { // TODO: add organizationId: - meteorSubscribe(PubSub.studios, {}) - meteorSubscribe(PubSub.showStyleBases, {}) - meteorSubscribe(PubSub.showStyleVariants, {}) - meteorSubscribe(PubSub.blueprints, {}) - meteorSubscribe(PubSub.peripheralDevices, {}) + meteorSubscribe(CorelibPubSub.studios, {}) + meteorSubscribe(CorelibPubSub.showStyleBases, {}) + meteorSubscribe(CorelibPubSub.showStyleVariants, {}) + meteorSubscribe(CorelibPubSub.blueprints, {}) + meteorSubscribe(CorelibPubSub.peripheralDevices, {}) return { studios: Studios.find({}).fetch(), diff --git a/meteor/client/ui/Settings/ShowStyle/BlueprintConfiguration/index.tsx b/meteor/client/ui/Settings/ShowStyle/BlueprintConfiguration/index.tsx index a09b55b851..ce7873a974 100644 --- a/meteor/client/ui/Settings/ShowStyle/BlueprintConfiguration/index.tsx +++ b/meteor/client/ui/Settings/ShowStyle/BlueprintConfiguration/index.tsx @@ -8,7 +8,7 @@ import { MappingsExt } from '@sofie-automation/corelib/dist/dataModel/Studio' import { DBShowStyleBase, SourceLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase' import { SelectConfigPreset } from './SelectConfigPreset' import { SelectBlueprint } from './SelectBlueprint' -import { PubSub } from '../../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../../lib/api/pubsub' import { useSubscription, useTracker } from '../../../../lib/ReactMeteorData/ReactMeteorData' import { UIBlueprintUpgradeStatuses } from '../../../Collections' import { getUpgradeStatusMessage, UpgradeStatusButtons } from '../../Upgrades/Components' @@ -27,7 +27,7 @@ export function ShowStyleBaseBlueprintConfigurationSettings( ): JSX.Element { const { t } = useTranslation() - const isStatusReady = useSubscription(PubSub.uiBlueprintUpgradeStatuses) + const isStatusReady = useSubscription(MeteorPubSub.uiBlueprintUpgradeStatuses) const status = useTracker( () => UIBlueprintUpgradeStatuses.findOne({ diff --git a/meteor/client/ui/Settings/SnapshotsView.tsx b/meteor/client/ui/Settings/SnapshotsView.tsx index e2bef3278e..e50f02fbb8 100644 --- a/meteor/client/ui/Settings/SnapshotsView.tsx +++ b/meteor/client/ui/Settings/SnapshotsView.tsx @@ -13,12 +13,13 @@ import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio' import { multilineText, fetchFrom } from '../../lib/lib' import { NotificationCenter, Notification, NoticeLevel } from '../../../lib/notifications/notifications' import { UploadButton } from '../../lib/uploadButton' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { MeteorCall } from '../../../lib/api/methods' import { SnapshotId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { Snapshots, Studios } from '../../collections' import { ClientAPI } from '../../../lib/api/client' import { hashSingleUseToken } from '../../../lib/api/userActions' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IProps { match: { @@ -59,12 +60,12 @@ export default translateWithTracker(() => { } } componentDidMount(): void { - this.subscribe(PubSub.snapshots, { + this.subscribe(MeteorPubSub.snapshots, { created: { $gt: getCurrentTime() - 30 * 24 * 3600 * 1000, // last 30 days }, }) - this.subscribe(PubSub.studios, {}) + this.subscribe(CorelibPubSub.studios, {}) } onUploadFile(e: React.ChangeEvent) { diff --git a/meteor/client/ui/Settings/Studio/BlueprintConfiguration/index.tsx b/meteor/client/ui/Settings/Studio/BlueprintConfiguration/index.tsx index 7da0ace786..1ea97f6a46 100644 --- a/meteor/client/ui/Settings/Studio/BlueprintConfiguration/index.tsx +++ b/meteor/client/ui/Settings/Studio/BlueprintConfiguration/index.tsx @@ -12,7 +12,7 @@ import { useTranslation } from 'react-i18next' import { DBStudio } from '@sofie-automation/corelib/dist/dataModel/Studio' import { SelectConfigPreset } from './SelectConfigPreset' import { SelectBlueprint } from './SelectBlueprint' -import { PubSub } from '../../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../../lib/api/pubsub' import { UIBlueprintUpgradeStatuses } from '../../../Collections' import { getUpgradeStatusMessage, UpgradeStatusButtons } from '../../Upgrades/Components' @@ -23,7 +23,7 @@ interface StudioBlueprintConfigurationSettingsProps { export function StudioBlueprintConfigurationSettings(props: StudioBlueprintConfigurationSettingsProps): JSX.Element { const { t } = useTranslation() - const isStatusReady = useSubscription(PubSub.uiBlueprintUpgradeStatuses) + const isStatusReady = useSubscription(MeteorPubSub.uiBlueprintUpgradeStatuses) const status = useTracker( () => UIBlueprintUpgradeStatuses.findOne({ diff --git a/meteor/client/ui/Settings/SystemManagement.tsx b/meteor/client/ui/Settings/SystemManagement.tsx index d2683b7114..878a6aa480 100644 --- a/meteor/client/ui/Settings/SystemManagement.tsx +++ b/meteor/client/ui/Settings/SystemManagement.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { translateWithTracker, Translated } from '../../lib/ReactMeteorData/ReactMeteorData' import { ICoreSystem, SofieLogo } from '../../../lib/collections/CoreSystem' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' -import { meteorSubscribe, PubSub } from '../../../lib/api/pubsub' +import { meteorSubscribe, MeteorPubSub } from '../../../lib/api/pubsub' import { EditAttribute } from '../../lib/EditAttribute' import { doModalDialog } from '../../lib/ModalDialog' import { MeteorCall } from '../../../lib/api/methods' @@ -30,7 +30,7 @@ export default translateWithTracker((_props: IProps) })( class SystemManagement extends MeteorReactComponent> { componentDidMount(): void { - meteorSubscribe(PubSub.coreSystem) + meteorSubscribe(MeteorPubSub.coreSystem) } cleanUpOldDatabaseIndexes(): void { const { t } = this.props diff --git a/meteor/client/ui/Settings/Upgrades/View.tsx b/meteor/client/ui/Settings/Upgrades/View.tsx index 059755e852..ca555e9fc3 100644 --- a/meteor/client/ui/Settings/Upgrades/View.tsx +++ b/meteor/client/ui/Settings/Upgrades/View.tsx @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next' import { Spinner } from '../../../lib/Spinner' import { unprotectString } from '@sofie-automation/corelib/dist/protectedString' import { useSubscription, useTracker } from '../../../lib/ReactMeteorData/ReactMeteorData' -import { PubSub } from '../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../lib/api/pubsub' import { UIBlueprintUpgradeStatuses } from '../../Collections' import { UIBlueprintUpgradeStatusShowStyle, UIBlueprintUpgradeStatusStudio } from '../../../../lib/api/upgradeStatus' import { getUpgradeStatusMessage, UpgradeStatusButtons } from './Components' @@ -11,7 +11,7 @@ import { getUpgradeStatusMessage, UpgradeStatusButtons } from './Components' export function UpgradesView(): JSX.Element { const { t } = useTranslation() - const isReady = useSubscription(PubSub.uiBlueprintUpgradeStatuses) + const isReady = useSubscription(MeteorPubSub.uiBlueprintUpgradeStatuses) const statuses = useTracker(() => UIBlueprintUpgradeStatuses.find().fetch(), []) diff --git a/meteor/client/ui/Settings/components/triggeredActions/TriggeredActionsEditor.tsx b/meteor/client/ui/Settings/components/triggeredActions/TriggeredActionsEditor.tsx index 5a539a3bba..9a9cc5d2fa 100644 --- a/meteor/client/ui/Settings/components/triggeredActions/TriggeredActionsEditor.tsx +++ b/meteor/client/ui/Settings/components/triggeredActions/TriggeredActionsEditor.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect, useContext, useCallback } from 'react' import { useTranslation } from 'react-i18next' import { useSubscription, useTracker } from '../../../../lib/ReactMeteorData/ReactMeteorData' -import { PubSub } from '../../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../../lib/api/pubsub' import { TriggeredActionsObj } from '../../../../../lib/collections/TriggeredActions' import { faCaretDown, faCaretRight, faDownload, faPlus, faUpload } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' @@ -31,6 +31,7 @@ import { PartInstances, Parts, RundownPlaylists, Rundowns, TriggeredActions } fr import { applyAndValidateOverrides } from '@sofie-automation/corelib/dist/settings/objectWithOverrides' import { SourceLayers, OutputLayers } from '@sofie-automation/corelib/dist/dataModel/ShowStyleBase' import { RundownPlaylistCollectionUtil } from '../../../../../lib/collections/rundownPlaylistUtil' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' export interface PreviewContext { rundownPlaylist: DBRundownPlaylist | null @@ -90,8 +91,8 @@ export const TriggeredActionsEditor: React.FC = function TriggeredAction ]), } - useSubscription(PubSub.triggeredActions, showStyleBaseSelector) - useSubscription(PubSub.rundowns, null, showStyleBaseId ? [showStyleBaseId] : []) + useSubscription(MeteorPubSub.triggeredActions, showStyleBaseSelector) + useSubscription(CorelibPubSub.rundowns, null, showStyleBaseId ? [showStyleBaseId] : []) useEffect(() => { const debounce = setTimeout(() => { @@ -166,7 +167,7 @@ export const TriggeredActionsEditor: React.FC = function TriggeredAction [showStyleBaseId, parsedTriggerFilter] ) - useSubscription(PubSub.rundownPlaylists, {}) + useSubscription(CorelibPubSub.rundownPlaylists, {}) const rundown = useTracker(() => { const activePlaylists = RundownPlaylists.find( @@ -205,8 +206,8 @@ export const TriggeredActionsEditor: React.FC = function TriggeredAction null ) - useSubscription(PubSub.partInstances, rundown ? [rundown._id] : [], rundownPlaylist?.activationId) - useSubscription(PubSub.parts, rundown ? [rundown._id] : []) + useSubscription(CorelibPubSub.partInstances, rundown ? [rundown._id] : [], rundownPlaylist?.activationId) + useSubscription(CorelibPubSub.parts, rundown ? [rundown._id] : []) const previewContext = useTracker( () => { diff --git a/meteor/client/ui/Settings/components/triggeredActions/triggerEditors/DeviceEditor.tsx b/meteor/client/ui/Settings/components/triggeredActions/triggerEditors/DeviceEditor.tsx index 6a6ceb05af..755c582518 100644 --- a/meteor/client/ui/Settings/components/triggeredActions/triggerEditors/DeviceEditor.tsx +++ b/meteor/client/ui/Settings/components/triggeredActions/triggerEditors/DeviceEditor.tsx @@ -2,7 +2,7 @@ import { IBlueprintDeviceTrigger } from '@sofie-automation/blueprints-integratio import { protectString, unprotectString } from '@sofie-automation/corelib/dist/protectedString' import classNames from 'classnames' import React, { useMemo } from 'react' -import { PubSub } from '../../../../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../../../../lib/api/pubsub' import { Studios } from '../../../../../collections' import { getCurrentTime } from '../../../../../../lib/lib' import { UIDeviceTriggerPreview } from '../../../../../../server/publications/deviceTriggersPreview' @@ -33,7 +33,7 @@ export const DeviceEditor = function DeviceEditor({ trigger, modified, readonly, ) const studio = useTracker(() => Studios.findOne(), [], undefined) - useSubscription(PubSub.deviceTriggersPreview, studio?._id ?? protectString('')) + useSubscription(MeteorPubSub.deviceTriggersPreview, studio?._id ?? protectString('')) return ( <> diff --git a/meteor/client/ui/Shelf/BucketPanel.tsx b/meteor/client/ui/Shelf/BucketPanel.tsx index 5a13eaf6cd..30f3d58ef6 100644 --- a/meteor/client/ui/Shelf/BucketPanel.tsx +++ b/meteor/client/ui/Shelf/BucketPanel.tsx @@ -23,7 +23,7 @@ import { IBlueprintActionTriggerMode, SomeContent, } from '@sofie-automation/blueprints-integration' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { doUserAction, getEventTimestamp, UserAction } from '../../../lib/clientUserAction' import { NotificationCenter, Notification, NoticeLevel } from '../../../lib/notifications/notifications' import { literal, unprotectString, partial, protectString } from '../../../lib/lib' @@ -72,6 +72,7 @@ import { ShowStyleVariantId, } from '@sofie-automation/corelib/dist/dataModel/Ids' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IBucketPanelDragObject { id: BucketId @@ -385,9 +386,9 @@ export const BucketPanel = translateWithTracker, I } componentDidMount(): void { - this.subscribe(PubSub.buckets, this.props.playlist.studioId, this.props.bucket._id) - this.subscribe(PubSub.uiBucketContentStatuses, this.props.playlist.studioId, this.props.bucket._id) - this.subscribe(PubSub.uiStudio, this.props.playlist.studioId) + this.subscribe(MeteorPubSub.buckets, this.props.playlist.studioId, this.props.bucket._id) + this.subscribe(MeteorPubSub.uiBucketContentStatuses, this.props.playlist.studioId, this.props.bucket._id) + this.subscribe(MeteorPubSub.uiStudio, this.props.playlist.studioId) this.autorun(() => { const showStyles: Array<[ShowStyleBaseId, ShowStyleVariantId]> = RundownPlaylistCollectionUtil.getRundownsUnordered(this.props.playlist).map((rundown) => [ @@ -396,14 +397,14 @@ export const BucketPanel = translateWithTracker, I ]) const showStyleBases = showStyles.map((showStyle) => showStyle[0]) const showStyleVariants = showStyles.map((showStyle) => showStyle[1]) - this.subscribe(PubSub.bucketAdLibPieces, { + this.subscribe(CorelibPubSub.bucketAdLibPieces, { bucketId: this.props.bucket._id, studioId: this.props.playlist.studioId, showStyleVariantId: { $in: [null, ...showStyleVariants], // null = valid for all variants }, }) - this.subscribe(PubSub.bucketAdLibActions, { + this.subscribe(CorelibPubSub.bucketAdLibActions, { bucketId: this.props.bucket._id, studioId: this.props.playlist.studioId, showStyleVariantId: { @@ -411,7 +412,7 @@ export const BucketPanel = translateWithTracker, I }, }) for (const showStyleBaseId of _.uniq(showStyleBases)) { - this.subscribe(PubSub.uiShowStyleBase, showStyleBaseId) + this.subscribe(MeteorPubSub.uiShowStyleBase, showStyleBaseId) } }) diff --git a/meteor/client/ui/Shelf/DashboardPanel.tsx b/meteor/client/ui/Shelf/DashboardPanel.tsx index 4364466e51..fddf988c5a 100644 --- a/meteor/client/ui/Shelf/DashboardPanel.tsx +++ b/meteor/client/ui/Shelf/DashboardPanel.tsx @@ -6,7 +6,6 @@ import ClassNames from 'classnames' import { Spinner } from '../../lib/Spinner' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { ISourceLayer, IBlueprintActionTriggerMode } from '@sofie-automation/blueprints-integration' -import { PubSub } from '../../../lib/api/pubsub' import { doUserAction, UserAction } from '../../../lib/clientUserAction' import { NotificationCenter, Notification, NoticeLevel } from '../../../lib/notifications/notifications' import { DashboardLayoutFilter, DashboardPanelUnit } from '../../../lib/collections/RundownLayouts' @@ -34,6 +33,7 @@ import { UIStudios } from '../Collections' import { Meteor } from 'meteor/meteor' import { PieceId } from '@sofie-automation/corelib/dist/dataModel/Ids' import { RundownPlaylistCollectionUtil } from '../../../lib/collections/rundownPlaylistUtil' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IState { outputLayers: OutputLayers @@ -167,7 +167,7 @@ export class DashboardPanelInner extends MeteorReactComponent< this.autorun(() => { const unorderedRundownIds = RundownPlaylistCollectionUtil.getRundownUnorderedIDs(this.props.playlist) if (unorderedRundownIds.length > 0) { - this.subscribe(PubSub.pieceInstances, { + this.subscribe(CorelibPubSub.pieceInstances, { rundownId: { $in: unorderedRundownIds, }, diff --git a/meteor/client/ui/Status.tsx b/meteor/client/ui/Status.tsx index 755ecbeea9..a3985854fc 100644 --- a/meteor/client/ui/Status.tsx +++ b/meteor/client/ui/Status.tsx @@ -9,9 +9,10 @@ import { ExternalMessages } from './Status/ExternalMessages' import { UserActivity } from './Status/UserActivity' import { EvaluationView } from './Status/Evaluations' import { MeteorReactComponent } from '../lib/MeteorReactComponent' -import { PubSub } from '../../lib/api/pubsub' +import { MeteorPubSub } from '../../lib/api/pubsub' import { ExpectedPackagesStatus } from './Status/package-status' import { MediaStatus } from './Status/media-status' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IStatusMenuProps { match?: any @@ -79,10 +80,10 @@ class Status extends MeteorReactComponent> { componentDidMount(): void { // Subscribe to data: - this.subscribe(PubSub.peripheralDevices, {}) - this.subscribe(PubSub.uiStudio, null) - this.subscribe(PubSub.showStyleBases, {}) - this.subscribe(PubSub.showStyleVariants, {}) + this.subscribe(CorelibPubSub.peripheralDevices, {}) + this.subscribe(MeteorPubSub.uiStudio, null) + this.subscribe(CorelibPubSub.showStyleBases, {}) + this.subscribe(CorelibPubSub.showStyleVariants, {}) } render(): JSX.Element { // const { t } = this.props diff --git a/meteor/client/ui/Status/Evaluations.tsx b/meteor/client/ui/Status/Evaluations.tsx index 0de5e28ff3..2a630bf91f 100644 --- a/meteor/client/ui/Status/Evaluations.tsx +++ b/meteor/client/ui/Status/Evaluations.tsx @@ -9,7 +9,7 @@ import { Evaluation } from '../../../lib/collections/Evaluations' import { DatePickerFromTo } from '../../lib/datePicker' import moment from 'moment' import { getQuestionOptions } from '../AfterBroadcastForm' -import { PubSub, meteorSubscribe } from '../../../lib/api/pubsub' +import { MeteorPubSub, meteorSubscribe } from '../../../lib/api/pubsub' import { Evaluations } from '../../collections' interface IEvaluationProps {} @@ -63,7 +63,7 @@ const EvaluationView = translateWithTracker { this.setState({ @@ -159,7 +160,7 @@ const ExternalMessagesInStudio = translateWithTracker< if (this._sub) { this._sub.stop() } - this._sub = meteorSubscribe(PubSub.externalMessageQueue, { + this._sub = meteorSubscribe(CorelibPubSub.externalMessageQueue, { studioId: this.props.studioId, created: { $gte: this.state.dateFrom, diff --git a/meteor/client/ui/Status/MediaManager.tsx b/meteor/client/ui/Status/MediaManager.tsx index cb50493026..d03bcc95f3 100644 --- a/meteor/client/ui/Status/MediaManager.tsx +++ b/meteor/client/ui/Status/MediaManager.tsx @@ -14,7 +14,7 @@ import * as i18next from 'react-i18next' import { extendMandadory, unprotectString } from '../../../lib/lib' import * as _ from 'underscore' import { MeteorReactComponent } from '../../lib/MeteorReactComponent' -import { PubSub } from '../../../lib/api/pubsub' +import { MeteorPubSub } from '../../../lib/api/pubsub' import { Spinner } from '../../lib/Spinner' import { sofieWarningIcon as WarningIcon } from '../../lib/notifications/warningIcon' import { doUserAction, UserAction } from '../../../lib/clientUserAction' @@ -378,8 +378,8 @@ export const MediaManagerStatus = translateWithTracker { diff --git a/meteor/client/ui/Status/SystemStatus.tsx b/meteor/client/ui/Status/SystemStatus.tsx index c01c9e406d..4347cf39bc 100644 --- a/meteor/client/ui/Status/SystemStatus.tsx +++ b/meteor/client/ui/Status/SystemStatus.tsx @@ -19,7 +19,6 @@ import { MeteorReactComponent } from '../../lib/MeteorReactComponent' import { callPeripheralDeviceAction, PeripheralDevicesAPI } from '../../lib/clientAPI' import { NotificationCenter, NoticeLevel, Notification } from '../../../lib/notifications/notifications' import { getAllowConfigure, getAllowDeveloper, getAllowStudio, getHelpMode } from '../../lib/localStorage' -import { PubSub } from '../../../lib/api/pubsub' import ClassNames from 'classnames' import { StatusCode, TSR } from '@sofie-automation/blueprints-integration' import { ICoreSystem } from '../../../lib/collections/CoreSystem' @@ -40,6 +39,7 @@ import { JSONBlobParse } from '@sofie-automation/shared-lib/dist/lib/JSONBlob' import { ClientAPI } from '../../../lib/api/client' import { catchError } from '../../lib/lib' import { logger } from '../../../lib/logging' +import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub' interface IDeviceItemProps { parentDevice: PeripheralDevice | null @@ -546,7 +546,7 @@ export default translateWithTracker(moment().startOf('day').valueOf()) const [dateTo, setDateTo] = useState