Skip to content

Commit 4a188cb

Browse files
committed
wip: cleanup
1 parent e3398c6 commit 4a188cb

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed

meteor/server/api/deviceTriggers/triggersContext.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IBaseFilterLink, IRundownPlaylistFilterLink } from '@sofie-automation/b
1515
import { PartId, StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
1616
import { DummyReactiveVar } from '@sofie-automation/meteor-lib/dist/triggers/reactive-var'
1717
import { ReactivePlaylistActionContext } from '@sofie-automation/meteor-lib/dist/triggers/actionFactory'
18-
import { MongoQuery } from '@sofie-automation/corelib/dist/mongo'
18+
import { FindOneOptions, FindOptions, MongoQuery } from '@sofie-automation/corelib/dist/mongo'
1919
import { DBRundownPlaylist, SelectedPartInstance } from '@sofie-automation/corelib/dist/dataModel/RundownPlaylist'
2020
import {
2121
AdLibActions,
@@ -47,16 +47,16 @@ class MeteorTriggersCollectionWrapper<DBInterface extends { _id: ProtectedString
4747

4848
async findFetchAsync(
4949
_computation: TriggerTrackerComputation | null,
50-
selector: any,
51-
options?: any
50+
selector: MongoQuery<DBInterface>,
51+
options?: FindOptions<DBInterface>
5252
): Promise<Array<DBInterface>> {
5353
return this.#collection.findFetchAsync(selector, options)
5454
}
5555

5656
async findOneAsync(
5757
_computation: TriggerTrackerComputation | null,
58-
selector: any,
59-
options?: any
58+
selector: MongoQuery<DBInterface> | DBInterface['_id'],
59+
options?: FindOneOptions<DBInterface>
6060
): Promise<DBInterface | undefined> {
6161
return this.#collection.findOneAsync(selector, options)
6262
}

packages/meteor-lib/src/triggers/actionFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ function createAdLibAction(
180180

181181
const sourceLayerIdsToClear: string[] = []
182182

183-
// This withComputation is probably not needed, but is a nice safeguard
183+
// This withComputation is probably not needed, but it ensures there is no accidental reactivity
184184
const wrappedAdLibs = await triggersContext.withComputation(null, async () =>
185185
compiledAdLibFilter(innerCtx, null)
186186
)

packages/webui/src/client/lib/notifications/notifications.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class NotifierHandle {
116116
this.result = source().get()
117117
notificationsDep.changed()
118118
})
119-
}) as any as Tracker.Computation
119+
})
120120

121121
notifiers[notifierId] = this
122122
}

packages/webui/src/client/lib/reactiveData/reactiveDataHelper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export abstract class WithManagedTracker {
8383
const comp = Tracker.autorun(func, options)
8484
this._autoruns.push(comp)
8585
return comp
86-
}) as any as Tracker.Computation
86+
})
8787
}
8888
}
8989

packages/webui/src/client/lib/triggers/TriggersHandler.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ import { RundownPlaylistCollectionUtil } from '../../collections/rundownPlaylist
4545
import { catchError } from '../lib'
4646
import { logger } from '../logging'
4747
import { CorelibPubSub } from '@sofie-automation/corelib/dist/pubsub'
48-
import { toTriggersReactiveVar, UiTriggersContext } from './triggersContext'
49-
import { TriggerTrackerComputation } from '@sofie-automation/meteor-lib/dist/triggers/triggersContext'
48+
import { toTriggersComputation, toTriggersReactiveVar, UiTriggersContext } from './triggersContext'
5049

5150
type HotkeyTriggerListener = (e: KeyboardEvent) => void
5251

@@ -105,7 +104,7 @@ function createAction(
105104
)
106105
return {
107106
preview: async (computation: Tracker.Computation) => {
108-
const trackerComputation = computation as any as TriggerTrackerComputation
107+
const trackerComputation = toTriggersComputation(computation)
109108
const ctx = collectContext(computation)
110109
if (!ctx) return []
111110

packages/webui/src/client/lib/triggers/triggersContext.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ import {
2222
import { logger } from '../logging'
2323
import { StudioId } from '@sofie-automation/corelib/dist/dataModel/Ids'
2424
import { ReactivePlaylistActionContext } from '@sofie-automation/meteor-lib/dist/triggers/actionFactory'
25-
import { MongoReadOnlyCollection } from '../../collections/lib'
25+
import { FindOneOptions, MongoReadOnlyCollection } from '../../collections/lib'
2626
import { ProtectedString } from '../tempLib'
2727
import { ReactiveVar as MeteorReactiveVar } from 'meteor/reactive-var'
2828
import { TriggerReactiveVar } from '@sofie-automation/meteor-lib/dist/triggers/reactive-var'
29+
import { FindOptions, MongoQuery } from '@sofie-automation/corelib/dist/mongo'
2930

3031
class UiTriggersCollectionWrapper<DBInterface extends { _id: ProtectedString<any> }>
3132
implements TriggersAsyncCollection<DBInterface>
@@ -38,8 +39,8 @@ class UiTriggersCollectionWrapper<DBInterface extends { _id: ProtectedString<any
3839

3940
async findFetchAsync(
4041
computation: TriggerTrackerComputation | null,
41-
selector: any,
42-
options?: any
42+
selector: MongoQuery<DBInterface>,
43+
options?: FindOptions<DBInterface>
4344
): Promise<Array<DBInterface>> {
4445
return Tracker.withComputation(computation as Tracker.Computation | null, async () => {
4546
return this.#collection.find(selector, options).fetch()
@@ -48,8 +49,8 @@ class UiTriggersCollectionWrapper<DBInterface extends { _id: ProtectedString<any
4849

4950
async findOneAsync(
5051
computation: TriggerTrackerComputation | null,
51-
selector: any,
52-
options?: any
52+
selector: MongoQuery<DBInterface> | DBInterface['_id'],
53+
options?: FindOneOptions<DBInterface>
5354
): Promise<DBInterface | undefined> {
5455
return Tracker.withComputation(computation as Tracker.Computation | null, async () => {
5556
return this.#collection.findOne(selector, options)
@@ -105,3 +106,7 @@ export const UiTriggersContext: TriggersContext = {
105106
export function toTriggersReactiveVar<T>(reactiveVar: MeteorReactiveVar<T>): TriggerReactiveVar<T> {
106107
return reactiveVar as any
107108
}
109+
110+
export function toTriggersComputation(computation: Tracker.Computation): TriggerTrackerComputation {
111+
return computation as any
112+
}

packages/webui/src/client/ui/Settings/components/triggeredActions/TriggeredActionEntry.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ import { isHotkeyTrigger } from '@sofie-automation/meteor-lib/dist/triggers/trig
3939
import { getAllCurrentAndDeletedItemsFromOverrides, useOverrideOpHelper } from '../../util/OverrideOpHelper'
4040
import { TriggeredActions } from '../../../../collections'
4141
import { catchError } from '../../../../lib/lib'
42-
import { UiTriggersContext } from '../../../../lib/triggers/triggersContext'
42+
import { toTriggersComputation, UiTriggersContext } from '../../../../lib/triggers/triggersContext'
4343
import { last, literal } from '@sofie-automation/shared-lib/dist/lib/lib'
44-
import { TriggerTrackerComputation } from '@sofie-automation/meteor-lib/dist/triggers/triggersContext'
4544

4645
interface IProps {
4746
sourceLayers: SourceLayers | undefined
@@ -189,7 +188,7 @@ export const TriggeredActionEntry: React.FC<IProps> = React.memo(function Trigge
189188
try {
190189
if (!resolvedActions || !selected || !sourceLayers) return []
191190

192-
const triggerComputation = computation as any as TriggerTrackerComputation
191+
const triggerComputation = toTriggersComputation(computation)
193192

194193
const executableActions = Object.values<SomeAction>(resolvedActions).map((value) =>
195194
createAction(UiTriggersContext, value, sourceLayers)

0 commit comments

Comments
 (0)