Fix iCloud sync: chart and next check-in date stale on secondary device (build 32)

- completedMonthKeys: remove UserDefaults-based MonthlyCheckInStore check (not synced via iCloud)
- MonthlyCheckInCard.effectiveLastCheckInDate: use max() instead of ?? to prefer newer synced snapshot date
- MonthlyCheckInView.lastCompletionDate: use max() of local + latest CoreData snapshot via @FetchRequest
- FirebaseService.logPaywallShown: fix parameter key to paywall_trigger (matches GA4 custom dimension)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
alexandrev-tibco
2026-05-24 08:42:22 +02:00
parent b48a47ce10
commit 0b01d6f563
5 changed files with 31 additions and 12 deletions
@@ -353,7 +353,10 @@ class DashboardViewModel: ObservableObject {
for (key, monthSnapshots) in groupedByMonth {
guard let monthDate = Calendar.current.date(from: key) else { continue }
guard monthDate > cutoff else { continue }
guard MonthlyCheckInStore.completionDate(for: monthDate) != nil else { continue }
// A month is "complete" if all active sources have snapshot data for it.
// We intentionally do NOT require a MonthlyCheckInStore entry here because
// that store lives in UserDefaults (device-local) and is not synced via iCloud.
// Snapshot data from CoreData is the authoritative cross-device source of truth.
let monthSourceIds = Set(monthSnapshots.compactMap { $0.source?.id })
if sourceIds.isSubset(of: monthSourceIds) {
completed.insert(key)