Skip to content

Commit

Permalink
check for verseObjects
Browse files Browse the repository at this point in the history
  • Loading branch information
klappy committed Dec 2, 2019
1 parent 741bc00 commit c8224c7
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/core/selections/verseObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,18 @@ export const getOccurrences = (words, subString) => {
* @return {verseObjects: Array} - clone of verseObjects and word map
*/
export const occurrenceInjectVerseObjects = (verseObjects) => {
const flattenedVerseObjects = flattenVerseObjects(verseObjects);
const _verseObjects = flattenedVerseObjects.map((verseObject, index) => {
let _verseObject = {...verseObject};
if (verseObject.type === 'word') {
const occurrence = getOccurrence(flattenedVerseObjects, index, verseObject.text);
const occurrences = getOccurrences(flattenedVerseObjects, verseObject.text);
_verseObject = {...verseObject, occurrence, occurrences};
}
return _verseObject;
});
let _verseObjects = [];
if (verseObjects && verseObjects.length > 0) {
const flattenedVerseObjects = flattenVerseObjects(verseObjects);
_verseObjects = flattenedVerseObjects.map((verseObject, index) => {
let _verseObject = {...verseObject};
if (verseObject.type === 'word') {
const occurrence = getOccurrence(flattenedVerseObjects, index, verseObject.text);
const occurrences = getOccurrences(flattenedVerseObjects, verseObject.text);
_verseObject = {...verseObject, occurrence, occurrences};
}
return _verseObject;
});
}
return _verseObjects;
};

0 comments on commit c8224c7

Please sign in to comment.