mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 06:31:26 +00:00
Clean up trending settings when feature flag is disabled
Add startup cleanup to remove trending-related settings when the feature flag is disabled: - Remove trending from visible sections - Reset startup section to home if it was set to trending - Remove all trending favorite items This ensures users don't have invalid/broken settings referencing the disabled trending feature.
This commit is contained in:
@@ -237,6 +237,10 @@ struct YatteeApp: App {
|
||||
self.migrateQualityProfiles()
|
||||
}
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
self.cleanupDisabledFeatures()
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
self.migrateRotateToLandscapeOnEnterFullScreen()
|
||||
@@ -291,6 +295,34 @@ struct YatteeApp: App {
|
||||
}
|
||||
#endif
|
||||
|
||||
func cleanupDisabledFeatures() {
|
||||
// Remove trending from visible sections if feature flag is disabled
|
||||
if !FeatureFlags.trendingEnabled {
|
||||
var visibleSections = Defaults[.visibleSections]
|
||||
if visibleSections.contains(.trending) {
|
||||
visibleSections.remove(.trending)
|
||||
Defaults[.visibleSections] = visibleSections
|
||||
}
|
||||
|
||||
// Reset startup section if set to trending
|
||||
if Defaults[.startupSection] == .trending {
|
||||
Defaults[.startupSection] = .home
|
||||
}
|
||||
|
||||
// Remove trending favorites
|
||||
let trendingFavorites = favorites.all.filter { item in
|
||||
if case .trending = item.section {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
for favorite in trendingFavorites {
|
||||
favorites.remove(favorite)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var navigationStyle: NavigationStyle {
|
||||
#if os(iOS)
|
||||
return horizontalSizeClass == .compact ? .tab : .sidebar
|
||||
|
||||
Reference in New Issue
Block a user