summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/viewer.actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'animism-align/frontend/app/views/viewer/viewer.actions.js')
-rw-r--r--animism-align/frontend/app/views/viewer/viewer.actions.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/animism-align/frontend/app/views/viewer/viewer.actions.js b/animism-align/frontend/app/views/viewer/viewer.actions.js
index 3d69b1f..aa5124f 100644
--- a/animism-align/frontend/app/views/viewer/viewer.actions.js
+++ b/animism-align/frontend/app/views/viewer/viewer.actions.js
@@ -2,30 +2,31 @@ import * as types from 'app/types'
import { store, history, dispatch } from 'app/store'
import { MEDIA_TYPES } from 'app/constants'
-const newSection = (annotation, index) => ({
+const newSection = (annotation, index, mediaIndex) => ({
start_ts: annotation.start_ts,
title: annotation.text,
media: [],
index,
+ mediaIndex,
})
export const loadSections = () => dispatch => {
- let sections = [], currentSection
+ let sections = [], currentSection, mediaIndex = 0
const state = store.getState()
const { order: annotationOrder, lookup: annotationLookup } = state.annotation.index
const { lookup: mediaLookup } = state.media.index
-
// loop over the annotations in time order. group the media found in each section.
annotationOrder.forEach((annotation_id, i) => {
const annotation = annotationLookup[annotation_id]
if (annotation.type === 'header') {
- currentSection = newSection(annotation, sections.length)
+ currentSection = newSection(annotation, sections.length, mediaIndex)
sections.push(currentSection)
}
if (MEDIA_TYPES.has(annotation.type)) {
if (currentSection) {
const media = mediaLookup[annotation.settings.media_id]
currentSection.media.push(media)
+ mediaIndex += 1
} else {
console.error("media found before first section")
}