Fix the day picker's workout-day dots missing on most days
The decorated-days set was built from dateComponents([.year, .month, .day], from:) output, which also sets isLeapMonth = false; the day picker probes it with bare y/m/d components (isLeapMonth nil). The two compare == but hash differently, so Set.contains missed essentially every member and dots appeared only on chance hash collisions. Build the set from bare y/m/d components matching the probe's shape. Claude-Session: https://claude.ai/code/session_012qw2itfzKyEJ1HpsFt8Ex4
This commit is contained in:
@@ -288,9 +288,20 @@ struct TodayView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Day-precision (year/month/day) components of every day with at least one
|
/// Day-precision (year/month/day) components of every day with at least one
|
||||||
/// logged workout — the day picker decorates these with a dot.
|
/// logged workout — the day picker decorates these with a dot. Built as *bare*
|
||||||
|
/// y/m/d components, not `dateComponents([.year, .month, .day], from:)` output:
|
||||||
|
/// the latter also sets `isLeapMonth = false`, which `==` ignores but hashing
|
||||||
|
/// doesn't — so a bare-components `Set.contains` probe (the day picker's) would
|
||||||
|
/// miss every member.
|
||||||
private var workoutDays: Set<DateComponents> {
|
private var workoutDays: Set<DateComponents> {
|
||||||
Set(workouts.map { Calendar.current.dateComponents([.year, .month, .day], from: $0.start) })
|
Set(workouts.map { workout in
|
||||||
|
let c = Calendar.current.dateComponents([.year, .month, .day], from: workout.start)
|
||||||
|
var day = DateComponents()
|
||||||
|
day.year = c.year
|
||||||
|
day.month = c.month
|
||||||
|
day.day = c.day
|
||||||
|
return day
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Row icon color: the routine's own color, or the goal's color as a generic
|
/// Row icon color: the routine's own color, or the goal's color as a generic
|
||||||
|
|||||||
Reference in New Issue
Block a user