Skip to content

Commit 5a35e49

Browse files
committed
Revert "wip: this probably doesn't work, need to figure out how to do reactivity correctly.."
This reverts commit 706e50a.
1 parent 706e50a commit 5a35e49

File tree

4 files changed

+53
-67
lines changed

4 files changed

+53
-67
lines changed

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

Lines changed: 50 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -634,34 +634,30 @@ export function compileAdLibFilter(
634634
// because _.isEqual (used in memoizedIsolatedAutorun) doesn't work with Maps..
635635

636636
const rundownPlaylistId = context.rundownPlaylistId.get()
637-
const rundownRanks = await triggersContext.memoizedIsolatedAutorun(
638-
async () => {
639-
const playlist = (await triggersContext.RundownPlaylists.findOneAsync(rundownPlaylistId, {
640-
projection: {
641-
rundownIdsInOrder: 1,
637+
const rundownRanks = await triggersContext.memoizedIsolatedAutorun(async () => {
638+
const playlist = (await triggersContext.RundownPlaylists.findOneAsync(rundownPlaylistId, {
639+
projection: {
640+
rundownIdsInOrder: 1,
641+
},
642+
})) as Pick<DBRundownPlaylist, 'rundownIdsInOrder'> | undefined
643+
644+
if (playlist?.rundownIdsInOrder) {
645+
return playlist.rundownIdsInOrder
646+
} else {
647+
const rundowns = (await triggersContext.Rundowns.findFetchAsync(
648+
{
649+
playlistId: rundownPlaylistId,
642650
},
643-
})) as Pick<DBRundownPlaylist, 'rundownIdsInOrder'> | undefined
644-
645-
if (playlist?.rundownIdsInOrder) {
646-
return playlist.rundownIdsInOrder
647-
} else {
648-
const rundowns = (await triggersContext.Rundowns.findFetchAsync(
649-
{
650-
playlistId: rundownPlaylistId,
651+
{
652+
fields: {
653+
_id: 1,
651654
},
652-
{
653-
fields: {
654-
_id: 1,
655-
},
656-
}
657-
)) as Pick<DBRundown, '_id'>[]
658-
659-
return rundowns.map((r) => r._id)
660-
}
661-
},
662-
reactive,
663-
`rundownsRanksForPlaylist_${rundownPlaylistId}`
664-
)
655+
}
656+
)) as Pick<DBRundown, '_id'>[]
657+
658+
return rundowns.map((r) => r._id)
659+
}
660+
}, `rundownsRanksForPlaylist_${rundownPlaylistId}`)
665661
rundownRanks.forEach((id, index) => {
666662
rundownRankMap.set(id, index)
667663
})
@@ -679,46 +675,41 @@ export function compileAdLibFilter(
679675
},
680676
}
681677
)) as Pick<DBSegment, '_id' | '_rank'>[],
682-
reactive,
683678
`segmentRanksForRundowns_${Array.from(rundownRankMap.keys()).join(',')}`
684679
)
685680
segmentRanks.forEach((segment) => {
686681
segmentRankMap.set(segment._id, segment._rank)
687682
})
688683

689-
const partRanks = await triggersContext.memoizedIsolatedAutorun(
690-
async () => {
691-
if (!partFilter) {
692-
return (await triggersContext.Parts.findFetchAsync(
693-
{
694-
rundownId: { $in: Array.from(rundownRankMap.keys()) },
684+
const partRanks = await triggersContext.memoizedIsolatedAutorun(async () => {
685+
if (!partFilter) {
686+
return (await triggersContext.Parts.findFetchAsync(
687+
{
688+
rundownId: { $in: Array.from(rundownRankMap.keys()) },
689+
},
690+
{
691+
fields: {
692+
_id: 1,
693+
segmentId: 1,
694+
rundownId: 1,
695+
_rank: 1,
695696
},
696-
{
697-
fields: {
698-
_id: 1,
699-
segmentId: 1,
700-
rundownId: 1,
701-
_rank: 1,
702-
},
703-
}
704-
)) as Pick<DBPart, '_id' | '_rank' | 'segmentId' | 'rundownId'>[]
705-
} else {
706-
return (await triggersContext.Parts.findFetchAsync(
707-
{ _id: { $in: partFilter } },
708-
{
709-
fields: {
710-
_id: 1,
711-
segmentId: 1,
712-
rundownId: 1,
713-
_rank: 1,
714-
},
715-
}
716-
)) as Pick<DBPart, '_id' | '_rank' | 'segmentId' | 'rundownId'>[]
717-
}
718-
},
719-
reactive,
720-
`partRanks_${JSON.stringify(partFilter ?? rundownRankMap.keys())}`
721-
)
697+
}
698+
)) as Pick<DBPart, '_id' | '_rank' | 'segmentId' | 'rundownId'>[]
699+
} else {
700+
return (await triggersContext.Parts.findFetchAsync(
701+
{ _id: { $in: partFilter } },
702+
{
703+
fields: {
704+
_id: 1,
705+
segmentId: 1,
706+
rundownId: 1,
707+
_rank: 1,
708+
},
709+
}
710+
)) as Pick<DBPart, '_id' | '_rank' | 'segmentId' | 'rundownId'>[]
711+
}
712+
}, `partRanks_${JSON.stringify(partFilter ?? rundownRankMap.keys())}`)
722713

723714
partRanks.forEach((part) => {
724715
partRankMap.set(part._id, part)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export interface TriggersContext {
4646

4747
memoizedIsolatedAutorun<TArgs extends any[], TRes>(
4848
fnc: (...args: TArgs) => Promise<TRes>,
49-
reactive: boolean,
5049
functionName: string,
5150
...params: TArgs
5251
): Promise<TRes>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ const isolatedAutorunsMem: {
1919
* If the `fnc` computation is invalidated, the outer computations will only be invalidated if the value returned from
2020
* `fnc` fails a deep equality check (_.isEqual).
2121
*
22+
* If used in server code, thie `fnc` will be run as-is, without any reactivity
23+
*
2224
* @export
2325
* @template T
2426
* @param {T} fnc The computation function to be memoized and calculated separately from the outer one.

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,7 @@ export const UiTriggersContext: TriggersContext = {
3939

4040
doUserAction: (...args) => Tracker.nonreactive(() => doUserAction(...args)),
4141

42-
memoizedIsolatedAutorun: async (fnc, reactive, functionName, ...params) => {
43-
if (!reactive) {
44-
return Tracker.nonreactive(() => memoizedIsolatedAutorun(fnc, functionName, ...params))
45-
} else {
46-
return memoizedIsolatedAutorun(fnc, functionName, ...params)
47-
}
48-
},
42+
memoizedIsolatedAutorun,
4943

5044
async createContextForRundownPlaylistChain(
5145
_studioId: StudioId,

0 commit comments

Comments
 (0)