Skip to content

Commit

Permalink
render default slide when loading content fails
Browse files Browse the repository at this point in the history
  • Loading branch information
waaaaargh committed Apr 27, 2024
1 parent a8a244a commit 7b247b4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/services/content/yamlTaskProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ import jsyaml from 'js-yaml'
import { IContent, isIContent } from '../../interfaces/Content'
import { Task, TaskGenerator } from './taskManager'
import getRenderer from '../../renderers/factory'
import MessageRenderer, { IMessageSlide } from '../../renderers/messageRenderer'

const defaultSlide: IMessageSlide = {
'duration': 10000,
'type': 'message',
'message': {
'text': 'lade inhalte...'
}
}

export default class HTTPYAMLTaskProvider implements TaskGenerator {
private tasks: Array<Task> = new Array<Task>()
Expand Down Expand Up @@ -48,10 +57,19 @@ export default class HTTPYAMLTaskProvider implements TaskGenerator {

async next(): Promise<Task> {
if (this.tasks.length == 0) {
this.tasks = await HTTPYAMLTaskProvider.loadTasks(this.endpointURL)
try {
this.tasks = await HTTPYAMLTaskProvider.loadTasks(this.endpointURL)
} catch (e) {
console.error(e)

this.tasks = [
new MessageRenderer(defaultSlide)
]
}
}

let task = this.tasks.pop()

if (!task) {
throw new Error('no tasks available')
} else {
Expand Down

0 comments on commit 7b247b4

Please sign in to comment.