mirror of
https://github.com/yattee/yattee.git
synced 2025-11-22 06:31:26 +00:00
Add feature flag to disable hide shorts functionality
The hide shorts feature is no longer working due to API changes that prevent reliable detection of short videos. This commit introduces a feature flag system to disable the functionality while preserving the ability to easily restore it if the API issue is resolved. Changes: - Add FeatureFlags.swift with hideShortsEnabled flag (currently disabled) - Hide all HideShortsButtons UI elements when flag is disabled - Disable shorts filtering logic in ContentItemView, FavoriteItemView, and FeedModel - Preserve hideShorts user preference for future restoration
This commit is contained in:
8
Shared/FeatureFlags.swift
Normal file
8
Shared/FeatureFlags.swift
Normal file
@@ -0,0 +1,8 @@
|
||||
import Foundation
|
||||
|
||||
/// Feature flags for enabling/disabling functionality across the app
|
||||
enum FeatureFlags {
|
||||
/// Controls whether the "Hide Shorts" functionality is available
|
||||
/// Set to false when the API changes prevent reliable detection of short videos
|
||||
static let hideShortsEnabled = false
|
||||
}
|
||||
@@ -50,9 +50,11 @@ struct FavoriteItemView: View {
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.foregroundColor(.secondary)
|
||||
|
||||
if hideShorts || hideWatched {
|
||||
if (FeatureFlags.hideShortsEnabled && hideShorts) || hideWatched {
|
||||
AccentButton(text: "Disable filters", maxWidth: nil, verticalPadding: 0, minHeight: 30) {
|
||||
hideShorts = false
|
||||
if FeatureFlags.hideShortsEnabled {
|
||||
hideShorts = false
|
||||
}
|
||||
hideWatched = false
|
||||
reloadVisibleWatches()
|
||||
}
|
||||
@@ -107,7 +109,7 @@ struct FavoriteItemView: View {
|
||||
resource?.removeObservers(ownedBy: store)
|
||||
}
|
||||
.onChange(of: player.currentVideo) { _ in if !player.presentingPlayer { reloadVisibleWatches() } }
|
||||
.onChange(of: hideShorts) { _ in if !player.presentingPlayer { reloadVisibleWatches() } }
|
||||
.onChange(of: hideShorts) { _ in if !player.presentingPlayer && FeatureFlags.hideShortsEnabled { reloadVisibleWatches() } }
|
||||
.onChange(of: hideWatched) { _ in if !player.presentingPlayer { reloadVisibleWatches() } }
|
||||
// Delay is necessary to update the list with the new items.
|
||||
.onChange(of: favoritesChanged) { _ in if !player.presentingPlayer { Delay.by(1.0) { reloadVisibleWatches() } } }
|
||||
@@ -135,9 +137,9 @@ struct FavoriteItemView: View {
|
||||
|
||||
var emptyItemsText: String {
|
||||
var filterText = ""
|
||||
if hideShorts && hideWatched {
|
||||
if FeatureFlags.hideShortsEnabled && hideShorts && hideWatched {
|
||||
filterText = "(watched and shorts hidden)"
|
||||
} else if hideShorts {
|
||||
} else if FeatureFlags.hideShortsEnabled && hideShorts {
|
||||
filterText = "(shorts hidden)"
|
||||
} else if hideWatched {
|
||||
filterText = "(watched hidden)"
|
||||
@@ -227,7 +229,7 @@ struct FavoriteItemView: View {
|
||||
return false
|
||||
}
|
||||
|
||||
guard hideShorts, item.contentType == .video, let video = item.video else {
|
||||
guard FeatureFlags.hideShortsEnabled, hideShorts, item.contentType == .video, let video = item.video else {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ struct ContentItemView: View {
|
||||
return false
|
||||
}
|
||||
|
||||
guard hideShorts, item.contentType == .video, let video = item.video else {
|
||||
guard FeatureFlags.hideShortsEnabled, hideShorts, item.contentType == .video, let video = item.video else {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -5,22 +5,24 @@ struct HideShortsButtons: View {
|
||||
@Default(.hideShorts) private var hideShorts
|
||||
|
||||
var body: some View {
|
||||
Button {
|
||||
hideShorts.toggle()
|
||||
} label: {
|
||||
Group {
|
||||
if hideShorts {
|
||||
Label("Short videos: hidden", systemImage: "bolt.slash.fill")
|
||||
.help("Short videos: hidden")
|
||||
} else {
|
||||
Label("Short videos: visible", systemImage: "bolt.fill")
|
||||
.help("Short videos: visible")
|
||||
if FeatureFlags.hideShortsEnabled {
|
||||
Button {
|
||||
hideShorts.toggle()
|
||||
} label: {
|
||||
Group {
|
||||
if hideShorts {
|
||||
Label("Short videos: hidden", systemImage: "bolt.slash.fill")
|
||||
.help("Short videos: hidden")
|
||||
} else {
|
||||
Label("Short videos: visible", systemImage: "bolt.fill")
|
||||
.help("Short videos: visible")
|
||||
}
|
||||
}
|
||||
#if os(tvOS)
|
||||
.font(.caption)
|
||||
.imageScale(.small)
|
||||
#endif
|
||||
}
|
||||
#if os(tvOS)
|
||||
.font(.caption)
|
||||
.imageScale(.small)
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user