Skip to content

Commit

Permalink
fix: keep checking status of loaded elements
Browse files Browse the repository at this point in the history
Potentially will remove the media object leading to updating the
status visible in the UI, in case the element gets unloaded because
of an engine restart
  • Loading branch information
ianshade committed Mar 30, 2021
1 parent ab6c76b commit 3085502
Showing 1 changed file with 29 additions and 32 deletions.
61 changes: 29 additions & 32 deletions src/devices/vizMSE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1366,44 +1366,41 @@ class VizMSEManager extends EventEmitter {
_.map(elementsToLoad, async (e) => {

const cachedEl = this._elementsLoaded[e.hash]
try {
const elementRef = await this._checkPrepareElement(e.item)

if (!cachedEl || !cachedEl.isLoaded) {
try {
const elementRef = await this._checkPrepareElement(e.item)
this.emit('debug', `Updating status of element ${elementRef}`)

this.emit('debug', `Updating status of element ${elementRef}`)
// Update cached status of the element:
const newEl = await rundown.getElement(elementRef)

// Update cached status of the element:
const newEl = await rundown.getElement(elementRef)

this._elementsLoaded[e.hash] = {
element: newEl,
isLoaded: this._isElementLoaded(newEl),
isLoading: this._isElementLoading(newEl)
}
this.emit('debug', `Element ${elementRef}: ${JSON.stringify(newEl)}`)
if (this._isExternalElement(newEl)) {
if (this._elementsLoaded[e.hash].isLoaded) {
const mediaObject: MediaObject = {
_id: e.hash,
mediaId: 'PILOT_' + e.item.templateName.toString().toUpperCase(),
mediaPath: e.item.templateInstance,
mediaSize: 0,
mediaTime: 0,
thumbSize: 0,
thumbTime: 0,
cinf: '',
tinf: '',
_rev: ''
}
this.emit('updateMediaObject', this._parentVizMSEDevice.deviceId, e.hash, mediaObject)
} else if (!cachedEl) {
this.emit('updateMediaObject', this._parentVizMSEDevice.deviceId, e.hash, null)
this._elementsLoaded[e.hash] = {
element: newEl,
isLoaded: this._isElementLoaded(newEl),
isLoading: this._isElementLoading(newEl)
}
this.emit('debug', `Element ${elementRef}: ${JSON.stringify(newEl)}`)
if (this._isExternalElement(newEl) && cachedEl?.isLoaded !== this._elementsLoaded[e.hash].isLoaded) {
if (this._elementsLoaded[e.hash].isLoaded) {
const mediaObject: MediaObject = {
_id: e.hash,
mediaId: 'PILOT_' + e.item.templateName.toString().toUpperCase(),
mediaPath: e.item.templateInstance,
mediaSize: 0,
mediaTime: 0,
thumbSize: 0,
thumbTime: 0,
cinf: '',
tinf: '',
_rev: ''
}
this.emit('updateMediaObject', this._parentVizMSEDevice.deviceId, e.hash, mediaObject)
} else {
this.emit('updateMediaObject', this._parentVizMSEDevice.deviceId, e.hash, null)
}
} catch (e) {
this.emit('error', `Error in updateElementsLoadedStatus: ${e.toString()}`)
}
} catch (e) {
this.emit('error', `Error in updateElementsLoadedStatus: ${e.toString()}`)
}
})
)
Expand Down

0 comments on commit 3085502

Please sign in to comment.