Fix lyrics wiped on schema reset by moving SavedSong to cloud container

SavedSong was in the local container alongside reference data, so it
got deleted whenever localStoreResetVersion was bumped. Move it to the
cloud container (CloudKit-synced) so saved songs persist across schema
changes. Update lyrics views to use cloudModelContextProvider.

Closes #4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trey t
2026-04-13 10:27:21 -05:00
parent 24cc05389e
commit 282cd1b3a3
3 changed files with 24 additions and 13 deletions
@@ -7,9 +7,11 @@ struct LyricsConfirmationView: View {
let result: LyricsSearchResult
let onSave: () -> Void
@Environment(\.modelContext) private var modelContext
@Environment(\.cloudModelContextProvider) private var cloudModelContextProvider
@Environment(\.dismiss) private var dismiss
private var cloudModelContext: ModelContext { cloudModelContextProvider() }
@State private var translatedEN = ""
@State private var isTranslating = true
@State private var translationError = false
@@ -207,8 +209,8 @@ struct LyricsConfirmationView: View {
albumArtURL: result.albumArtURL ?? "",
appleMusicURL: result.appleMusicURL ?? ""
)
modelContext.insert(song)
try? modelContext.save()
cloudModelContext.insert(song)
try? cloudModelContext.save()
onSave()
}
}