summaryrefslogtreecommitdiff
path: root/animism-align/frontend/app/views/viewer/viewer.actions.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2020-07-27 19:42:05 +0200
committerJules Laplace <julescarbon@gmail.com>2020-07-27 19:42:05 +0200
commite22cb8a789c0576738fe0965a8f4242a3d3c76af (patch)
tree226e5ec4298f67125ac9c8953e708c84365b7879 /animism-align/frontend/app/views/viewer/viewer.actions.js
parenta43615e0c0d4edc34a0f4a14172e559f00be298a (diff)
process list of paragraphs. fullscreen vs inline
Diffstat (limited to 'animism-align/frontend/app/views/viewer/viewer.actions.js')
-rw-r--r--animism-align/frontend/app/views/viewer/viewer.actions.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/animism-align/frontend/app/views/viewer/viewer.actions.js b/animism-align/frontend/app/views/viewer/viewer.actions.js
index 3d5fe49..ed92bb6 100644
--- a/animism-align/frontend/app/views/viewer/viewer.actions.js
+++ b/animism-align/frontend/app/views/viewer/viewer.actions.js
@@ -1,6 +1,10 @@
import * as types from 'app/types'
import { store, history, dispatch } from 'app/store'
-import { MEDIA_ANNOTATION_TYPES, MEDIA_LABEL_TYPES } from 'app/constants'
+import {
+ MEDIA_ANNOTATION_TYPES, MEDIA_LABEL_TYPES,
+ TEXT_ANNOTATION_TYPES, UTILITY_ANNOTATION_TYPES,
+} from 'app/constants'
+import { buildParagraphs } from 'app/utils/transcript.utils'
const newSection = (annotation, index, mediaIndex) => ({
start_ts: annotation.start_ts,
@@ -15,20 +19,27 @@ export const loadSections = () => dispatch => {
let currentSection
let mediaIndex = 0
let mediaLabels = {}
+ let sectionAnnotationOrder = []
+
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 === 'section_heading') {
if (currentSection) {
currentSection.mediaLabels = Object.keys(mediaLabels).join(', ')
+ currentSection.paragraphs = buildParagraphs(sectionAnnotationOrder)
mediaLabels = {}
+ sectionAnnotationOrder = []
}
currentSection = newSection(annotation, sections.length, mediaIndex)
sections.push(currentSection)
}
+
if (MEDIA_ANNOTATION_TYPES.has(annotation.type)) {
if (currentSection) {
const media = mediaLookup[annotation.settings.media_id]
@@ -40,14 +51,29 @@ export const loadSections = () => dispatch => {
mediaLabels[MEDIA_LABEL_TYPES[media.type]] = true
}
mediaIndex += 1
+ // non-fullscreen media should be displayed inline in the transcript
+ if (!annotation.settings.fullscreen && !annotation.settings.inline) {
+ sectionAnnotationOrder.push(annotation.id)
+ }
} else {
console.error("media found before first section")
}
}
+
+ // group media into sections
+ // group annotations by section, group into paragraphs
+ if (UTILITY_ANNOTATION_TYPES.has(annotation.type) || annotation.settings.fullscreen) {
+ }
+
+ if (TEXT_ANNOTATION_TYPES.has(annotation.type)) {
+ sectionAnnotationOrder.push(annotation.id)
+ }
+
})
if (currentSection && Object.keys(mediaLabels).length) {
currentSection.mediaLabels = Object.keys(mediaLabels).join(', ')
+ currentSection.paragraphs = buildParagraphs(sectionAnnotationOrder)
}
// console.log(sections)