mirror of
https://github.com/yattee/yattee.git
synced 2026-05-14 03:15:03 +00:00
Show watch progress bar on thumbnails in playlist, channel, and search views
These views rendered video thumbnails without passing watchProgress, so the progress bar was silently missing. Apply the existing pattern from SubscriptionsView: maintain a watchEntriesMap and forward watchProgress(for:) to VideoRowView/VideoCardView at each call site.
This commit is contained in:
@@ -64,6 +64,7 @@ struct SearchView: View {
|
||||
|
||||
// Grid layout configuration
|
||||
@State private var viewWidth: CGFloat = 0
|
||||
@State private var watchEntriesMap: [String: WatchEntry] = [:]
|
||||
private var gridConfig: GridLayoutConfiguration {
|
||||
GridLayoutConfiguration(viewWidth: viewWidth, gridColumns: gridColumns)
|
||||
}
|
||||
@@ -152,6 +153,12 @@ struct SearchView: View {
|
||||
.onReceive(NotificationCenter.default.publisher(for: .searchHistoryDidChange)) { _ in
|
||||
loadSearchHistory()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .watchHistoryDidChange)) { _ in
|
||||
loadWatchEntries()
|
||||
}
|
||||
.task {
|
||||
loadWatchEntries()
|
||||
}
|
||||
.onReceive(NotificationCenter.default.publisher(for: .recentChannelsDidChange)) { _ in
|
||||
loadRecentChannels()
|
||||
}
|
||||
@@ -1110,7 +1117,7 @@ struct SearchView: View {
|
||||
) {
|
||||
switch item {
|
||||
case .video(let video, let videoIndex):
|
||||
VideoRowView(video: video, style: rowStyle)
|
||||
VideoRowView(video: video, style: rowStyle, watchProgress: watchProgress(for: video))
|
||||
.tappableVideo(
|
||||
video,
|
||||
queueSource: searchQueueSource,
|
||||
@@ -1181,6 +1188,7 @@ struct SearchView: View {
|
||||
case .video(let video, let videoIndex):
|
||||
VideoCardView(
|
||||
video: video,
|
||||
watchProgress: watchProgress(for: video),
|
||||
isCompact: gridConfig.isCompactCards
|
||||
)
|
||||
.frame(maxHeight: .infinity, alignment: .top)
|
||||
@@ -1252,6 +1260,16 @@ struct SearchView: View {
|
||||
|
||||
// MARK: - Search History Helpers
|
||||
|
||||
private func loadWatchEntries() {
|
||||
watchEntriesMap = appEnvironment?.dataManager.watchEntriesMap() ?? [:]
|
||||
}
|
||||
|
||||
private func watchProgress(for video: Video) -> Double? {
|
||||
guard let entry = watchEntriesMap[video.id.videoID] else { return nil }
|
||||
let progress = entry.progress
|
||||
return progress > 0 && progress < 1 ? progress : nil
|
||||
}
|
||||
|
||||
private func loadSearchHistory() {
|
||||
guard appEnvironment?.settingsManager.saveRecentSearches != false else {
|
||||
searchHistory = []
|
||||
|
||||
Reference in New Issue
Block a user