diff --git a/KisaniCal/Models/ExerciseModels.swift b/KisaniCal/Models/ExerciseModels.swift index f600299..e168cce 100644 --- a/KisaniCal/Models/ExerciseModels.swift +++ b/KisaniCal/Models/ExerciseModels.swift @@ -190,7 +190,13 @@ class WorkoutViewModel: ObservableObject { let saved = try? JSONDecoder().decode([WorkoutProgram].self, from: data), !saved.isEmpty { - programs = saved + let gamifiedEmojis: Set = ["🔥", "💥"] + let emojiMap = ["🔥": "🔄", "💥": "🏋️"] + let needsMigration = saved.contains(where: { gamifiedEmojis.contains($0.emoji) }) + programs = needsMigration ? saved.map { p in + guard let replacement = emojiMap[p.emoji] else { return p } + var copy = p; copy.emoji = replacement; return copy + } : saved var sched: [Int: UUID] = [:] if let dict = UserDefaults.standard.dictionary(forKey: Self.kSchedule) as? [String: String] { @@ -205,7 +211,9 @@ class WorkoutViewModel: ObservableObject { let uid = UUID(uuidString: str), saved.contains(where: { $0.id == uid }) { pid = uid } activeProgramId = pid - activeSections = saved.first { $0.id == pid }?.sections ?? saved[0].sections + activeSections = programs.first { $0.id == pid }?.sections ?? programs[0].sections + + if needsMigration { save() } } else { // ── First launch: seed with sample programs ──