diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-08-13 20:15:08 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-08-13 20:15:08 +0200 |
| commit | 45cf182c73a6eb019bf7e61cafa3ca117b014ddb (patch) | |
| tree | 52dec0319e4fdbd0c2028dd3a6765ad3508d834c /animism-align/frontend/app/views/viewer/viewer.actions.js | |
| parent | a0cfa87f52a9ba82a3f35878bbe7ab8221804e60 (diff) | |
gallery vs carousel
Diffstat (limited to 'animism-align/frontend/app/views/viewer/viewer.actions.js')
| -rw-r--r-- | animism-align/frontend/app/views/viewer/viewer.actions.js | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/animism-align/frontend/app/views/viewer/viewer.actions.js b/animism-align/frontend/app/views/viewer/viewer.actions.js index ae2bf5b..6efe644 100644 --- a/animism-align/frontend/app/views/viewer/viewer.actions.js +++ b/animism-align/frontend/app/views/viewer/viewer.actions.js @@ -34,6 +34,7 @@ export const loadSections = () => dispatch => { // dedupe the labels that we see in each section let currentMediaLabels = {} + let seenMedia = {} // keep track of all annotations that constitute the "text" of the essay // these include sentences, headings, and inline media. used to build paragraphs, then reset. @@ -58,7 +59,7 @@ export const loadSections = () => dispatch => { if (annotation.type === 'section_heading') { // finish off the previous section. if (currentSection) { - currentSection.mediaLabels = Object.keys(currentMediaLabels).join(', ') + currentSection.mediaLabels = Object.keys(currentMediaLabels).sort().join(', ') currentSection.paragraphs = buildParagraphs(sectionTextAnnotationOrder, currentSection.index) currentSection.end_ts = currentSection.paragraphs[currentSection.paragraphs.length - 1].end_ts } @@ -80,16 +81,18 @@ export const loadSections = () => dispatch => { if (MEDIA_ANNOTATION_TYPES.has(annotation.type)) { // fetch the media and add it to the list of media (TODO: handle carousels) const media = mediaLookup[annotation.settings.media_id] - if (!media.settings.hide_in_bibliography) { + if (!media.settings.hide_in_bibliography && !(media.id in seenMedia)) { currentSection.media.push({ start_ts: annotation.start_ts, media }) + seenMedia[media.id] = true } // get the display string for this media type - if (media.type in MEDIA_LABEL_TYPES) { - currentMediaLabels[MEDIA_LABEL_TYPES[media.type]] = true + // console.log(annotation.type, media.type) + if (annotation.type in MEDIA_LABEL_TYPES) { + currentMediaLabels[MEDIA_LABEL_TYPES[annotation.type]] = true } // increment the media tally @@ -120,7 +123,7 @@ export const loadSections = () => dispatch => { // finished processing all annotations. finish off the last section. if (currentSection) { - currentSection.mediaLabels = Object.keys(currentMediaLabels).join(', ') + currentSection.mediaLabels = Object.keys(currentMediaLabels).sort().join(', ') currentSection.paragraphs = buildParagraphs(sectionTextAnnotationOrder, currentSection.index) currentSection.end_ts = timeline.duration } |
