From f2d612de04da968a74efe94d0b448b465869d6e0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 24 Jul 2020 22:26:07 +0200 Subject: navigate to media --- .../frontend/app/views/viewer/viewer.actions.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'animism-align/frontend/app/views/viewer/viewer.actions.js') diff --git a/animism-align/frontend/app/views/viewer/viewer.actions.js b/animism-align/frontend/app/views/viewer/viewer.actions.js index aa5124f..563b18f 100644 --- a/animism-align/frontend/app/views/viewer/viewer.actions.js +++ b/animism-align/frontend/app/views/viewer/viewer.actions.js @@ -11,7 +11,10 @@ const newSection = (annotation, index, mediaIndex) => ({ }) export const loadSections = () => dispatch => { - let sections = [], currentSection, mediaIndex = 0 + let sections = [] + let currentSection + let mediaIndex = 0 + let mediaTypes = {} const state = store.getState() const { order: annotationOrder, lookup: annotationLookup } = state.annotation.index const { lookup: mediaLookup } = state.media.index @@ -19,13 +22,20 @@ export const loadSections = () => dispatch => { annotationOrder.forEach((annotation_id, i) => { const annotation = annotationLookup[annotation_id] if (annotation.type === 'header') { + if (currentSection) { + currentSection.mediaTypes = Object.keys(mediaTypes).join(', ') + mediaTypes = {} + } 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) + currentSection.media.push({ + start_ts: annotation.start_ts, + media + }) mediaIndex += 1 } else { console.error("media found before first section") @@ -33,6 +43,10 @@ export const loadSections = () => dispatch => { } }) + if (currentSection) { + currentSection.mediaTypes = Object.keys(mediaTypes).join(', ') + } + // console.log(sections) dispatch({ type: types.viewer.load_sections, data: sections }) -- cgit v1.2.3-70-g09d2