Commit a4a03668 authored by anton's avatar anton

Properly check for existence of annotation body and and body.type

parent fba83e1b
......@@ -323,13 +323,20 @@
if (this.annotations) {
if (this.groupAnnotationsBy === 'type') {
groups = this.annotations.reduce((sum, annotation) => {
const type = annotation.body.type.indexOf('SpecificResource') > -1 ? annotation.body.source.type : annotation.body.type
if (sum.indexOf(type) === -1) sum.push(type)
if (annotation.body) {
const type = typeof annotation.body.type === 'string' && annotation.body.type.indexOf('SpecificResource') > -1
? annotation.body.source.type : annotation.body.type
if (sum.indexOf(type) === -1) sum.push(type)
}
return sum
}, [])
for (let group of groups) {
filtered[group] = this.annotations.filter(annotation => {
return (annotation.body.type.indexOf('SpecificResource') > -1 ? annotation.body.source.type : annotation.body.type) === group
if (annotation.body) {
return (typeof annotation.body.type === 'string' && annotation.body.type.indexOf('SpecificResource') > -1
? annotation.body.source.type : annotation.body.type) === group
}
return false
})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment