mirror of
https://github.com/yattee/yattee.git
synced 2025-04-29 08:20:33 +05:30
Preload history videos on home appear
This commit is contained in:
parent
dba8fa59b2
commit
09aabcf1e5
@ -1,6 +1,8 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct HistoryView: View {
|
struct HistoryView: View {
|
||||||
|
static let detailsPreloadLimit = 50
|
||||||
|
|
||||||
@FetchRequest(sortDescriptors: [.init(key: "watchedAt", ascending: false)])
|
@FetchRequest(sortDescriptors: [.init(key: "watchedAt", ascending: false)])
|
||||||
var watches: FetchedResults<Watch>
|
var watches: FetchedResults<Watch>
|
||||||
|
|
||||||
@ -15,7 +17,6 @@ struct HistoryView: View {
|
|||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "clock")
|
Image(systemName: "clock")
|
||||||
Text("Playback history is empty")
|
Text("Playback history is empty")
|
||||||
|
|
||||||
}.foregroundColor(.secondary)
|
}.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -24,15 +25,18 @@ struct HistoryView: View {
|
|||||||
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
|
item: PlayerQueueItem.from(watch, video: player.historyVideo(watch.videoID)),
|
||||||
history: true
|
history: true
|
||||||
)
|
)
|
||||||
.onAppear {
|
|
||||||
player.loadHistoryVideoDetails(watch.videoID)
|
|
||||||
}
|
|
||||||
.contextMenu {
|
.contextMenu {
|
||||||
VideoContextMenuView(video: player.historyVideo(watch.videoID) ?? watch.video)
|
VideoContextMenuView(video: player.historyVideo(watch.videoID) ?? watch.video)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.onAppear {
|
||||||
|
visibleWatches
|
||||||
|
.prefix(Self.detailsPreloadLimit)
|
||||||
|
.map(\.videoID)
|
||||||
|
.forEach(player.loadHistoryVideoDetails)
|
||||||
|
}
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.padding(.horizontal, 40)
|
.padding(.horizontal, 40)
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user