From bab55fb2b208e978ff52459f643cad53f01af08e Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 27 Jul 2020 17:27:49 +0200 Subject: media labels.. --- animism-align/frontend/app/views/viewer/viewer.actions.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 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 563b18f..73e34fd 100644 --- a/animism-align/frontend/app/views/viewer/viewer.actions.js +++ b/animism-align/frontend/app/views/viewer/viewer.actions.js @@ -1,6 +1,6 @@ import * as types from 'app/types' import { store, history, dispatch } from 'app/store' -import { MEDIA_TYPES } from 'app/constants' +import { MEDIA_TYPES, MEDIA_LABEL_TYPES } from 'app/constants' const newSection = (annotation, index, mediaIndex) => ({ start_ts: annotation.start_ts, @@ -14,7 +14,7 @@ export const loadSections = () => dispatch => { let sections = [] let currentSection let mediaIndex = 0 - let mediaTypes = {} + let mediaLabels = {} const state = store.getState() const { order: annotationOrder, lookup: annotationLookup } = state.annotation.index const { lookup: mediaLookup } = state.media.index @@ -23,8 +23,8 @@ export const loadSections = () => dispatch => { const annotation = annotationLookup[annotation_id] if (annotation.type === 'header') { if (currentSection) { - currentSection.mediaTypes = Object.keys(mediaTypes).join(', ') - mediaTypes = {} + currentSection.mediaLabels = Object.keys(mediaLabels).join(', ') + mediaLabels = {} } currentSection = newSection(annotation, sections.length, mediaIndex) sections.push(currentSection) @@ -36,6 +36,9 @@ export const loadSections = () => dispatch => { start_ts: annotation.start_ts, media }) + if (media.type in MEDIA_LABEL_TYPES) { + mediaLabels[MEDIA_LABEL_TYPES[media.type]] = true + } mediaIndex += 1 } else { console.error("media found before first section") @@ -43,8 +46,8 @@ export const loadSections = () => dispatch => { } }) - if (currentSection) { - currentSection.mediaTypes = Object.keys(mediaTypes).join(', ') + if (currentSection && Object.keys(mediaLabels).length) { + currentSection.mediaLabels = Object.keys(mediaLabels).join(', ') } // console.log(sections) -- cgit v1.2.3-70-g09d2