Skip to content

Commit

Permalink
Merge pull request #1334 from nrkno/fix/sofie-3638/device-action-cont…
Browse files Browse the repository at this point in the history
…ext-lost

fix(Core/Publications/Device Triggers): Device Action Studio Context gets lost, Adlib previews are unstable (SOFIE-3638)
  • Loading branch information
jstarpl authored Dec 4, 2024
2 parents fb50990 + 193815d commit 1478b68
Show file tree
Hide file tree
Showing 4 changed files with 225 additions and 155 deletions.
8 changes: 6 additions & 2 deletions meteor/server/api/deviceTriggers/RundownContentObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RundownContentObserver {
#observers: Meteor.LiveQueryHandle[] = []
#cache: ContentCache
#cancelCache: () => void
#cleanup: () => void = () => {
#cleanup: (() => void) | undefined = () => {
throw new Error('RundownContentObserver.#cleanup has not been set!')
}
#disposed = false
Expand All @@ -45,8 +45,11 @@ export class RundownContentObserver {
) {
logger.silly(`Creating RundownContentObserver for playlist "${rundownPlaylistId}"`)
const { cache, cancel: cancelCache } = createReactiveContentCache(() => {
if (this.#disposed) {
this.#cleanup?.()
return
}
this.#cleanup = onChanged(cache)
if (this.#disposed) this.#cleanup()
}, REACTIVITY_DEBOUNCE)

this.#cache = cache
Expand Down Expand Up @@ -157,5 +160,6 @@ export class RundownContentObserver {
this.#cancelCache()
this.#observers.forEach((observer) => observer.stop())
this.#cleanup?.()
this.#cleanup = undefined
}
}
Loading

0 comments on commit 1478b68

Please sign in to comment.