Hi @Polyphonic,
So, section.builds is an array. We have an array of all available builds. The first element in this array is the current build, and I want to highlight it as such. In that line it is grabbing the first item from the builds array and then mapping that to the SectionItem type. currentBuild itself is just a single item and not an array. I decided to restructure the Section type to remove this confusion.
struct Section: Hashable {
public let branch: String
public let currentBuild: Build
public let additionalBuilds: [Build]
}
// Updated snapshot code for the above type
var snapshot = Snapshot()
snapshot.appendSections(sections.map(\.branch))
apply(snapshot, animatingDifferences: animatingDifferences)
sections.forEach { section in
var sectionSnapshot = SectionSnapshot()
let currentBuild = SectionItem.currentBuild(section.currentBuild)
sectionSnapshot.append([currentBuild])
if section.additionalBuilds.isEmpty == false {
let additionalBuildsHeader = SectionItem.additionalBuildsHeader(forSection: section.branch)
sectionSnapshot.append([additionalBuildsHeader])
let additionalBuilds = section.additionalBuilds.map({ SectionItem.additionalBuild($0) })
sectionSnapshot.append(additionalBuilds, to: additionalBuildsHeader)
if expandedSections.contains(additionalBuildsHeader) {
sectionSnapshot.expand([additionalBuildsHeader])
}
}
apply(sectionSnapshot, to: section.branch, animatingDifferences: animatingDifferences)
}
The issue is still present, however.