fix(status): show gray cell instead of crashing on an empty day
AmSatParser deliberately uses getOrNull + mapNotNull while reading each day's 12 slots, so a shortened HTML row can legitimately produce SatDay(slots=[]). StatusRow then selected the first non-gray slot and fell back to slots.first(), which throws NoSuchElementException and crashes the entire AMSAT status screen. Use firstOrNull for both lookups and render a zero-count gray placeholder when no slot exists. Real amsat.org HTML currently has all 41 satellite rows at the full 73 cells, but the parser's own tolerance contract means the UI must handle what it can emit. Verified against the live page: parser matches 41/41 rows and 477/477 reports; :feature:status:compileReleaseKotlin BUILD SUCCESSFUL.
This commit is contained in:
1 parent
5f1f90067f
commit
828f720955
1 file changed
+7
-1
+7
-1
@@ -280,7 +280,13 @@ private fun StatusRow(status: SatStatus, onClickDay: (SatDay) -> Unit) {
|
|||||||
modifier = Modifier.weight(2f).padding(start = 4.dp)
|
modifier = Modifier.weight(2f).padding(start = 4.dp)
|
||||||
)
|
)
|
||||||
status.days.forEach { day ->
|
status.days.forEach { day ->
|
||||||
val slot = day.slots.firstOrNull { it.statusColor != noReportGray } ?: day.slots.first()
|
// A day can legitimately carry no slots: the parser skips cells it
|
||||||
|
// cannot find, so a page that ships fewer than 12 cells for a day
|
||||||
|
// yields an empty list. first() would crash the whole status screen,
|
||||||
|
// so fall back to a gray placeholder instead.
|
||||||
|
val slot = day.slots.firstOrNull { it.statusColor != noReportGray }
|
||||||
|
?: day.slots.firstOrNull()
|
||||||
|
?: SatSlot(statusColor = noReportGray, count = 0)
|
||||||
DayCell(
|
DayCell(
|
||||||
slot = slot,
|
slot = slot,
|
||||||
modifier = Modifier.weight(0.8f).padding(horizontal = 1.dp),
|
modifier = Modifier.weight(0.8f).padding(horizontal = 1.dp),
|
||||||
|
|||||||
Reference in new issue
Block a user