Load draft content in admin while keeping public lesson locks
This commit is contained in:
@@ -119,19 +119,33 @@ function isSectionReleased(section) {
|
||||
return releaseTime <= Date.now()
|
||||
}
|
||||
|
||||
function redactUnreleasedSection(section) {
|
||||
if (!section || typeof section !== 'object') return section
|
||||
if (isSectionReleased(section)) return section
|
||||
|
||||
return {
|
||||
...section,
|
||||
passageText: '',
|
||||
commentary: '',
|
||||
greekNotes: [],
|
||||
studyQuestions: [],
|
||||
audioEmbedUrl: '',
|
||||
}
|
||||
}
|
||||
|
||||
function filterSiteContentByReleaseDate(siteContent) {
|
||||
if (!siteContent || typeof siteContent !== 'object' || Array.isArray(siteContent)) return siteContent
|
||||
|
||||
const filteredStudies = Array.isArray(siteContent.studies)
|
||||
? siteContent.studies.map(study => {
|
||||
if (!study || typeof study !== 'object') return study
|
||||
const sections = Array.isArray(study.sections) ? study.sections.filter(isSectionReleased) : []
|
||||
const sections = Array.isArray(study.sections) ? study.sections.map(redactUnreleasedSection) : []
|
||||
return { ...study, sections }
|
||||
})
|
||||
: siteContent.studies
|
||||
|
||||
const filteredLegacySections = Array.isArray(siteContent.colossiansStudySections)
|
||||
? siteContent.colossiansStudySections.filter(isSectionReleased)
|
||||
? siteContent.colossiansStudySections.map(redactUnreleasedSection)
|
||||
: siteContent.colossiansStudySections
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user