mirror of
https://github.com/bellingcat/ukraine-timemap.git
synced 2026-06-12 05:18:34 +03:00
add support for showing filter descriptions in narrativised mode
This commit is contained in:
@@ -198,3 +198,16 @@ export function binarySearch (ar, el, compareFn) {
|
||||
}
|
||||
return -m - 1
|
||||
}
|
||||
|
||||
export const isFilterLeaf = node => (Object.keys(node.children).length === 0)
|
||||
export const isFilterDuplicate = (node, set) => { return (set.has(node.key)) }
|
||||
|
||||
export function findDescriptionInFilterTree (key, node) {
|
||||
if (node.key === key) return node.description
|
||||
if (isFilterLeaf(node)) return false
|
||||
const descs = Object.keys(node.children)
|
||||
.map(c => findDescriptionInFilterTree(key, node.children[c]))
|
||||
.filter(v => !!v)
|
||||
if (descs.length !== 1) return false
|
||||
return descs[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user