1
0
mirror of https://github.com/yattee/yattee.git synced 2025-04-28 07:50:33 +05:30

Preload history videos on home appear

This commit is contained in:
Arkadiusz Fal 2022-11-14 18:46:50 +01:00
parent dba8fa59b2
commit 09aabcf1e5

View File

@ -1,6 +1,8 @@
import SwiftUI
struct HistoryView: View {
static let detailsPreloadLimit = 50
@FetchRequest(sortDescriptors: [.init(key: "watchedAt", ascending: false)])
var watches: FetchedResults<Watch>
@ -15,7 +17,6 @@ struct HistoryView: View {
HStack {
Image(systemName: "clock")
Text("Playback history is empty")
}.foregroundColor(.secondary)
}
} else {
@ -24,15 +25,18 @@ struct HistoryView: View {
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
history: true
)
.onAppear {
player.loadHistoryVideoDetails(watch.videoID)
}
.contextMenu {
VideoContextMenuView(video: player.historyVideo(watch.videoID) ?? watch.video)
}
}
}
}
.onAppear {
visibleWatches
.prefix(Self.detailsPreloadLimit)
.map(\.videoID)
.forEach(player.loadHistoryVideoDetails)
}
#if os(tvOS)
.padding(.horizontal, 40)
#else