fix: multiple bug fixes and improvements
- Fix suggested trips showing wrong sports for cross-country trips - Remove quick start sections from home variants (Classic, Spotify) - Remove dead quickActions code from HomeView - Fix pace capsule animation in TripCreationView - Add text wrapping to achievement descriptions - Improve poll parsing with better error handling - Various sharing system improvements Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -510,17 +510,49 @@ struct CKTripPoll {
|
||||
}
|
||||
|
||||
func toPoll() -> TripPoll? {
|
||||
// Required fields with explicit guards for better debugging
|
||||
guard let pollIdString = record[CKTripPoll.pollIdKey] as? String,
|
||||
let pollId = UUID(uuidString: pollIdString),
|
||||
let title = record[CKTripPoll.titleKey] as? String,
|
||||
let ownerId = record[CKTripPoll.ownerIdKey] as? String,
|
||||
let shareCode = record[CKTripPoll.shareCodeKey] as? String,
|
||||
let tripsData = record[CKTripPoll.tripSnapshotsKey] as? Data,
|
||||
let tripSnapshots = try? JSONDecoder().decode([Trip].self, from: tripsData),
|
||||
let tripVersions = record[CKTripPoll.tripVersionsKey] as? [String],
|
||||
let createdAt = record[CKTripPoll.createdAtKey] as? Date,
|
||||
let modifiedAt = record[CKTripPoll.modifiedAtKey] as? Date
|
||||
else { return nil }
|
||||
let pollId = UUID(uuidString: pollIdString)
|
||||
else {
|
||||
print("CKTripPoll.toPoll: Failed to parse pollId")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let title = record[CKTripPoll.titleKey] as? String else {
|
||||
print("CKTripPoll.toPoll: Missing title for poll \(pollId)")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let ownerId = record[CKTripPoll.ownerIdKey] as? String else {
|
||||
print("CKTripPoll.toPoll: Missing ownerId for poll \(pollId)")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let shareCode = record[CKTripPoll.shareCodeKey] as? String else {
|
||||
print("CKTripPoll.toPoll: Missing shareCode for poll \(pollId)")
|
||||
return nil
|
||||
}
|
||||
|
||||
guard let createdAt = record[CKTripPoll.createdAtKey] as? Date else {
|
||||
print("CKTripPoll.toPoll: Missing createdAt for poll \(pollId)")
|
||||
return nil
|
||||
}
|
||||
|
||||
// modifiedAt defaults to createdAt if missing
|
||||
let modifiedAt = record[CKTripPoll.modifiedAtKey] as? Date ?? createdAt
|
||||
|
||||
// Decode trip snapshots - this is the most likely failure point
|
||||
var tripSnapshots: [Trip] = []
|
||||
if let tripsData = record[CKTripPoll.tripSnapshotsKey] as? Data {
|
||||
do {
|
||||
tripSnapshots = try JSONDecoder().decode([Trip].self, from: tripsData)
|
||||
} catch {
|
||||
print("CKTripPoll.toPoll: Failed to decode tripSnapshots for poll \(pollId): \(error)")
|
||||
// Return poll with empty trips rather than failing completely
|
||||
}
|
||||
} else {
|
||||
print("CKTripPoll.toPoll: Missing tripSnapshots data for poll \(pollId)")
|
||||
}
|
||||
|
||||
var poll = TripPoll(
|
||||
id: pollId,
|
||||
@@ -531,8 +563,13 @@ struct CKTripPoll {
|
||||
createdAt: createdAt,
|
||||
modifiedAt: modifiedAt
|
||||
)
|
||||
// Preserve the actual stored versions (not recomputed)
|
||||
poll.tripVersions = tripVersions
|
||||
|
||||
// tripVersions is optional - it's recomputed if missing
|
||||
if let storedVersions = record[CKTripPoll.tripVersionsKey] as? [String] {
|
||||
poll.tripVersions = storedVersions
|
||||
}
|
||||
// Otherwise, keep the computed versions from init
|
||||
|
||||
return poll
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user