summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/site/site.actions.js
blob: 1c51b532bcd441f28f677cc7537a5c093a51f599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import * as types from 'app/types'
import { api } from 'app/utils'
import actions from 'app/actions'
import { URLS } from 'app/constants'
import FontFaceObserver from 'fontfaceobserver'

export const loadSite = () => dispatch => {
  Promise.all([
    loadFonts(),
    actions.project.index(),
    actions.episode.index(),
    actions.venue.index(),
  ]).then(() => {
  }).catch(err => {
    console.error(err)
  })
}

export const loadEpisode = (episode) => dispatch => {
  Promise.all([
    // actions.site.loadText(episode),
    actions.site.loadPeaks(episode),
    actions.audio.load(episode),
    actions.annotation.index({ episode_id: episode.id }),
    actions.paragraph.index({ episode_id: episode.id }),
    actions.media.index({ episode_id: episode.id }),
  ]).then(() => {
    actions.viewer.loadSections()
  }).catch(err => {
    console.error(err)
  })
}

const loadFonts = () => {
  const fonts = [
    new FontFaceObserver('Freight Text'),
    new FontFaceObserver('Freight Text', { style: 'italic' }),
    new FontFaceObserver('Neue Haas Unica'),
  ]
  return Promise.all(fonts.map(font => font.load()))
}

export const loadPeaks = (asdf) => dispatch => (
  api(dispatch, types.peaks, 'peaks', URLS.peaks)
)

// export const loadText = (asdf) => dispatch => (
  // api(dispatch, types.text, 'text', URLS.text)
// )

export const updateText = text => dispatch => (
  dispatch({ type: types.text.loaded, data: text })
)