Skip to content

Commit

Permalink
Fix small bug that mistakenly showed data error for certain concepts
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Oct 28, 2024
1 parent a891128 commit f1d6b70
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/items/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ export function saveItem(item, options = {}) {
if (!item.type.includes(typeUri)) {
item.type = [typeUri].concat(item.type)
}
if (item.topConcepts?.length && !item.concepts?.length) {
item.concepts = [null]
}
// ? Anything else?
}
if (type === "concept") {
Expand Down Expand Up @@ -289,6 +292,10 @@ export async function loadTop(scheme, { registry, force = false } = {}) {
return saveItem(concept, { type: "concept", scheme })
})
modifyItem(scheme, "topConcepts", jskos.sortConcepts(topConcepts, !!_.get(scheme, "DISPLAY.numericalNotation")).map(mapMinimalProps))
// Also add [null] to `concepts`
if (!scheme.concepts?.length) {
modifyItem(scheme, "concepts", [null])
}
} catch (error) {
// Ignore error, show warning only.
log.warn(`Error loading top concepts for scheme ${scheme.uri}; assuming empty list.`)
Expand Down

0 comments on commit f1d6b70

Please # to comment.