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:
@@ -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()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user