mirror of
https://github.com/yattee/yattee.git
synced 2026-10-26 14:42:53 +00:00
Add a Hide Shorts toggle to the view options
Videos carry isShort from Yattee Server and Piped, and Invidious feed entries are taken as Shorts when they arrive with no length and aren't live or upcoming: the feed comes from RSS, which lists Shorts, while lengths come from the Videos tab, which doesn't. Subscriptions, search and instance browse hide videos known to be Shorts when the toggle is on; videos whose source can't tell are always shown.
This commit is contained in:
@@ -18,7 +18,10 @@ struct ViewOptionsSheet: View {
|
||||
|
||||
/// Optional binding for hide watched toggle (only shown if provided).
|
||||
var hideWatched: Binding<Bool>?
|
||||
|
||||
|
||||
/// Optional binding for hide shorts toggle (only shown if provided).
|
||||
var hideShorts: Binding<Bool>?
|
||||
|
||||
/// Optional binding for channel strip size (only shown if provided).
|
||||
var channelStripSize: Binding<ChannelStripSize>?
|
||||
|
||||
@@ -74,6 +77,10 @@ struct ViewOptionsSheet: View {
|
||||
Toggle("viewOptions.hideWatched", isOn: hideWatched)
|
||||
}
|
||||
|
||||
if let hideShorts = hideShorts {
|
||||
Toggle("viewOptions.hideShorts", isOn: hideShorts)
|
||||
}
|
||||
|
||||
if let channelStripSize = channelStripSize {
|
||||
PlatformMenuPicker(String(localized: "viewOptions.channelStrip"), selection: channelStripSize) {
|
||||
ForEach(ChannelStripSize.allCases, id: \.self) { size in
|
||||
@@ -140,6 +147,10 @@ struct ViewOptionsSheet: View {
|
||||
Toggle("viewOptions.hideWatched", isOn: hideWatched)
|
||||
}
|
||||
|
||||
if let hideShorts = hideShorts {
|
||||
Toggle("viewOptions.hideShorts", isOn: hideShorts)
|
||||
}
|
||||
|
||||
// Channel Strip (subscriptions only)
|
||||
if let channelStripSize = channelStripSize {
|
||||
PlatformMenuPicker(String(localized: "viewOptions.channelStrip"), selection: channelStripSize) {
|
||||
|
||||
@@ -50,6 +50,7 @@ struct InstanceBrowseView: View {
|
||||
@AppStorage var rowStyle: VideoRowStyle
|
||||
@AppStorage var gridColumnCount: Int
|
||||
@AppStorage var hideWatched: Bool
|
||||
@AppStorage var hideShorts: Bool
|
||||
|
||||
// View options UI state
|
||||
@State private var showViewOptions = false
|
||||
@@ -74,6 +75,7 @@ struct InstanceBrowseView: View {
|
||||
_rowStyle = AppStorage(wrappedValue: .regular, "instanceBrowse.\(instance.id).rowStyle")
|
||||
_gridColumnCount = AppStorage(wrappedValue: 2, "instanceBrowse.\(instance.id).gridColumns")
|
||||
_hideWatched = AppStorage(wrappedValue: false, "instanceBrowse.\(instance.id).hideWatched")
|
||||
_hideShorts = AppStorage(wrappedValue: false, "instanceBrowse.\(instance.id).hideShorts")
|
||||
}
|
||||
|
||||
/// List style from centralized settings.
|
||||
@@ -126,6 +128,7 @@ struct InstanceBrowseView: View {
|
||||
rowStyle: $rowStyle,
|
||||
gridColumns: $gridColumnCount,
|
||||
hideWatched: $hideWatched,
|
||||
hideShorts: $hideShorts,
|
||||
maxGridColumns: gridConfig.maxColumns
|
||||
)
|
||||
}
|
||||
@@ -826,6 +829,10 @@ struct InstanceBrowseView: View {
|
||||
return !entry.isFinished
|
||||
}
|
||||
}
|
||||
|
||||
if hideShorts {
|
||||
videos = videos.filter { !$0.isKnownShort }
|
||||
}
|
||||
|
||||
return videos
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ struct SearchView: View {
|
||||
@AppStorage("searchRowStyle") private var rowStyle: VideoRowStyle = .regular
|
||||
@AppStorage("searchGridColumns") private var gridColumns = 2
|
||||
@AppStorage("searchHideWatched") private var hideWatched = false
|
||||
@AppStorage("searchHideShorts") private var hideShorts = false
|
||||
|
||||
/// List style from centralized settings.
|
||||
private var listStyle: VideoListStyle {
|
||||
@@ -172,6 +173,9 @@ struct SearchView: View {
|
||||
.onChange(of: hideWatched) { _, newValue in
|
||||
searchViewModel?.hideWatchedVideos = newValue
|
||||
}
|
||||
.onChange(of: hideShorts) { _, newValue in
|
||||
searchViewModel?.hideShorts = newValue
|
||||
}
|
||||
.onChange(of: saveRecentSearches) { _, _ in
|
||||
loadSearchHistory()
|
||||
}
|
||||
@@ -203,6 +207,7 @@ struct SearchView: View {
|
||||
rowStyle: $rowStyle,
|
||||
gridColumns: $gridColumns,
|
||||
hideWatched: $hideWatched,
|
||||
hideShorts: $hideShorts,
|
||||
maxGridColumns: gridConfig.maxColumns
|
||||
)
|
||||
}
|
||||
@@ -389,6 +394,7 @@ struct SearchView: View {
|
||||
settingsManager: appEnvironment.settingsManager
|
||||
)
|
||||
searchViewModel?.hideWatchedVideos = hideWatched
|
||||
searchViewModel?.hideShorts = hideShorts
|
||||
loadFilters()
|
||||
loadSearchHistory()
|
||||
loadRecentChannels()
|
||||
@@ -410,6 +416,7 @@ struct SearchView: View {
|
||||
settingsManager: appEnvironment.settingsManager
|
||||
)
|
||||
searchViewModel?.hideWatchedVideos = hideWatched
|
||||
searchViewModel?.hideShorts = hideShorts
|
||||
loadFilters()
|
||||
|
||||
// Re-run search if we had results
|
||||
|
||||
@@ -44,6 +44,7 @@ struct SubscriptionsView: View {
|
||||
@AppStorage("subscriptionsRowStyle") private var rowStyle: VideoRowStyle = .regular
|
||||
@AppStorage("subscriptionsGridColumns") private var gridColumns = 2
|
||||
@AppStorage("subscriptionsHideWatched") private var hideWatched = false
|
||||
@AppStorage("subscriptionsHideShorts") private var hideShorts = false
|
||||
@AppStorage("subscriptionsChannelStripSize") private var channelStripSize: ChannelStripSize = .normal
|
||||
@AppStorage("subscriptionsShowSidebar") private var showSidebar = true
|
||||
/// Whether the last completed load produced enough channels for the sidebar,
|
||||
@@ -126,8 +127,13 @@ struct SubscriptionsView: View {
|
||||
Text("common.on").tag(true)
|
||||
Text("common.off").tag(false)
|
||||
}
|
||||
PlatformMenuPicker(String(localized: "viewOptions.hideShorts"), selection: $hideShorts) {
|
||||
Text("common.on").tag(true)
|
||||
Text("common.off").tag(false)
|
||||
}
|
||||
#else
|
||||
Toggle("viewOptions.hideWatched", isOn: $hideWatched)
|
||||
Toggle("viewOptions.hideShorts", isOn: $hideShorts)
|
||||
#endif
|
||||
|
||||
#if os(iOS)
|
||||
@@ -245,7 +251,7 @@ struct SubscriptionsView: View {
|
||||
.joined(separator: "|")
|
||||
}
|
||||
|
||||
/// Videos filtered by selected channel and watch status.
|
||||
/// Videos filtered by selected channel, watch status and Shorts.
|
||||
private var filteredVideos: [Video] {
|
||||
var videos = feedCache.videos
|
||||
|
||||
@@ -253,6 +259,10 @@ struct SubscriptionsView: View {
|
||||
videos = videos.filter { $0.author.id == channelID }
|
||||
}
|
||||
|
||||
if hideShorts {
|
||||
videos = videos.filter { !$0.isKnownShort }
|
||||
}
|
||||
|
||||
if hideWatched {
|
||||
videos = videos.filter { video in
|
||||
guard let entry = watchEntriesMap[video.id.videoID] else { return true }
|
||||
|
||||
Reference in New Issue
Block a user