Add feature flag to disable Trending functionality

Introduces a feature flag to disable the Trending section across the app. When disabled, all trending-related UI elements, navigation links, and settings are hidden.

Changes:
- Add trendingEnabled feature flag to FeatureFlags.swift (currently disabled)
- Hide Trending tab in AppTabNavigation, Sidebar, and TVNavigationView
- Remove Trending option from visible sections settings
- Remove Trending option from startup section picker
- Disable Trending menu command and keyboard shortcut
- Prevent Trending URL navigation in OpenURLHandler
- Hide Trending in FavoriteItemView navigation
This commit is contained in:
Arkadiusz Fal
2025-11-20 13:14:31 +01:00
parent e723bb9147
commit 5b607687d9
8 changed files with 23 additions and 11 deletions

View File

@@ -5,4 +5,8 @@ enum FeatureFlags {
/// Controls whether the "Hide Shorts" functionality is available /// Controls whether the "Hide Shorts" functionality is available
/// Set to false when the API changes prevent reliable detection of short videos /// Set to false when the API changes prevent reliable detection of short videos
static let hideShortsEnabled = false static let hideShortsEnabled = false
/// Controls whether the "Trending" section is available
/// Set to false to disable trending functionality across the app
static let trendingEnabled = false
} }

View File

@@ -353,7 +353,7 @@ struct FavoriteItemView: View {
case .history: case .history:
return false return false
case .trending: case .trending:
return visibleSections.contains(.trending) return FeatureFlags.trendingEnabled && visibleSections.contains(.trending)
case .subscriptions: case .subscriptions:
return visibleSections.contains(.subscriptions) && accounts.signedIn return visibleSections.contains(.subscriptions) && accounts.signedIn
case .popular: case .popular:

View File

@@ -39,6 +39,7 @@ struct MenuCommands: Commands {
Button("Trending") { Button("Trending") {
setTabSelection(.trending) setTabSelection(.trending)
} }
.disabled(!FeatureFlags.trendingEnabled)
.keyboardShortcut("4") .keyboardShortcut("4")
Button("Search") { Button("Search") {

View File

@@ -37,7 +37,7 @@ struct AppTabNavigation: View {
popularNavigationView popularNavigationView
} }
if visibleSections.contains(.trending) { if FeatureFlags.trendingEnabled && visibleSections.contains(.trending) {
trendingNavigationView trendingNavigationView
} }

View File

@@ -101,7 +101,7 @@ struct Sidebar: View {
.id("popular") .id("popular")
} }
if visibleSections.contains(.trending) { if FeatureFlags.trendingEnabled && visibleSections.contains(.trending) {
NavigationLink(destination: LazyView(TrendingView()), tag: TabSelection.trending, selection: $navigation.tabSelection) { NavigationLink(destination: LazyView(TrendingView()), tag: TabSelection.trending, selection: $navigation.tabSelection) {
Label("Trending", systemImage: "arrow.up.right.circle.fill") Label("Trending", systemImage: "arrow.up.right.circle.fill")
.accessibility(label: Text("Trending")) .accessibility(label: Text("Trending"))

View File

@@ -74,6 +74,7 @@ struct OpenURLHandler {
focusMainWindow() focusMainWindow()
#endif #endif
case .trending: case .trending:
guard FeatureFlags.trendingEnabled else { return }
navigation.hideViewsAboveBrowser() navigation.hideViewsAboveBrowser()
navigation.tabSelection = .trending navigation.tabSelection = .trending
#if os(macOS) #if os(macOS)

View File

@@ -258,6 +258,7 @@ struct BrowsingSettings: View {
private var visibleSectionsSettings: some View { private var visibleSectionsSettings: some View {
Section(header: SettingsHeader(text: "Sections".localized())) { Section(header: SettingsHeader(text: "Sections".localized())) {
ForEach(VisibleSection.allCases, id: \.self) { section in ForEach(VisibleSection.allCases, id: \.self) { section in
if section != .trending || FeatureFlags.trendingEnabled {
MultiselectRow( MultiselectRow(
title: section.title, title: section.title,
selected: visibleSections.contains(section) selected: visibleSections.contains(section)
@@ -267,6 +268,7 @@ struct BrowsingSettings: View {
} }
} }
} }
}
private var startupSectionPicker: some View { private var startupSectionPicker: some View {
Group { Group {
@@ -279,17 +281,21 @@ struct BrowsingSettings: View {
Spacer() Spacer()
Picker("Startup section", selection: $startupSection) { Picker("Startup section", selection: $startupSection) {
ForEach(StartupSection.allCases, id: \.rawValue) { section in ForEach(StartupSection.allCases, id: \.rawValue) { section in
if section != .trending || FeatureFlags.trendingEnabled {
Text(section.label).tag(section) Text(section.label).tag(section)
} }
} }
}
.modifier(SettingsPickerModifier()) .modifier(SettingsPickerModifier())
} }
#else #else
Picker("Startup section", selection: $startupSection) { Picker("Startup section", selection: $startupSection) {
ForEach(StartupSection.allCases, id: \.rawValue) { section in ForEach(StartupSection.allCases, id: \.rawValue) { section in
if section != .trending || FeatureFlags.trendingEnabled {
Text(section.label).tag(section) Text(section.label).tag(section)
} }
} }
}
.modifier(SettingsPickerModifier()) .modifier(SettingsPickerModifier())
#endif #endif
} }

View File

@@ -29,7 +29,7 @@ struct TVNavigationView: View {
.tag(TabSelection.popular) .tag(TabSelection.popular)
} }
if visibleSections.contains(.trending) { if FeatureFlags.trendingEnabled && visibleSections.contains(.trending) {
LazyView(TrendingView()) LazyView(TrendingView())
.tabItem { Text("Trending") } .tabItem { Text("Trending") }
.tag(TabSelection.trending) .tag(TabSelection.trending)