From 9a8ccc366c49c2e4ec9445a9967f59316c8061a7 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Thu, 20 Nov 2025 13:21:56 +0100 Subject: [PATCH] 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. --- Shared/YatteeApp.swift | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Shared/YatteeApp.swift b/Shared/YatteeApp.swift index 7cf23dbf..e55f60c2 100644 --- a/Shared/YatteeApp.swift +++ b/Shared/YatteeApp.swift @@ -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