Skip to content

Commit

Permalink
fix to combine the bibles list from the ult and abs
Browse files Browse the repository at this point in the history
  • Loading branch information
PhotoNomad0 committed Dec 6, 2023
1 parent 4fda19b commit 5827b94
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/components/WorkspaceContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ function WorkspaceContainer() {
/**
@todo 'ult' might be confusing for developers, could we create constants for these hardcoded values to
give more meaning to them?
@todo replace 'obs' with 'ult'
@todo replace 'obs' with 'ult'
*/
resourceId: languageId === 'en' ? 'ult' : 'glt',
owner,
Expand All @@ -369,32 +369,41 @@ function WorkspaceContainer() {
server,
})

const obsResources = getResourceBibles({
const obsResources = getResourceBibles({
bookId,
chapter,
verse,
/**
@todo 'ult' might be confusing for developers, could we create constants for these hardcoded values to
give more meaning to them?
@todo replace 'obs' with 'ult'
@todo replace 'obs' with 'ult'
*/
resourceId: 'obs',
owner,
languageId,
ref: appRef,
server,
})
})

Promise.all([getCanonicalResources, obsResources]).then(arrayOfResults => arrayOfResults.flat()).then(results => {
const { bibles, resourceLink } = results
// const { bibles, resourceLink } = results
const combinedBibles = []

if (results?.length) {
results.forEach(result => {
if (result?.bibles) {
Array.prototype.push.apply(combinedBibles, result?.bibles)
}
})
}

if (bibles?.length) {
if (!isEqual(bibles, supportedBibles)) {
console.log(`found ${bibles?.length} bibles`)
setSupportedBibles(bibles) // TODO blm: update bible refs
if (combinedBibles?.length) {
if (!isEqual(combinedBibles, supportedBibles)) {
console.log(`found ${combinedBibles?.length} bibles`)
setSupportedBibles(combinedBibles) // TODO blm: update bible refs
}
} else {
console.warn(`no bibles found for ${resourceLink}`)
console.warn(`no bibles found for ${results[0]?.resourceLink}`)
}
setState( { workspaceReady: true })
}).catch((e) => {
Expand Down

0 comments on commit 5827b94

Please sign in to comment.