add migration for old profiles to new format

This commit is contained in:
Toni Förster 2024-05-01 14:30:19 +02:00
parent 54915dcea1
commit ef7a486fd4
No known key found for this signature in database
GPG Key ID: 292F3E5086C83FC7

View File

@ -204,6 +204,7 @@ struct YatteeApp: App {
URLBookmarkModel.shared.refreshAll() URLBookmarkModel.shared.refreshAll()
migrateHomeHistoryItems() migrateHomeHistoryItems()
migrateQualityProfiles()
} }
func migrateHomeHistoryItems() { func migrateHomeHistoryItems() {
@ -221,6 +222,16 @@ struct YatteeApp: App {
Defaults[.homeHistoryItems] = -1 Defaults[.homeHistoryItems] = -1
} }
@Default(.qualityProfiles) private var qualityProfilesData
func migrateQualityProfiles() {
for profile in qualityProfilesData where profile.order.isEmpty {
var updatedProfile = profile
updatedProfile.order = Array(QualityProfile.Format.allCases.indices)
QualityProfilesModel.shared.update(profile, updatedProfile)
}
}
var navigationStyle: NavigationStyle { var navigationStyle: NavigationStyle {
#if os(iOS) #if os(iOS)
return horizontalSizeClass == .compact ? .tab : .sidebar return horizontalSizeClass == .compact ? .tab : .sidebar