Use cache for loading player queue and history

This commit is contained in:
Arkadiusz Fal
2022-12-13 00:38:26 +01:00
parent 33a131d2ca
commit 1c746bc8e0
11 changed files with 66 additions and 53 deletions

View File

@@ -8,6 +8,8 @@ struct PlayerQueueItem: Hashable, Identifiable, Defaults.Serializable {
var id = UUID()
var video: Video!
var videoID: Video.ID
var app: VideosApp?
var instanceURL: URL?
var playbackTime: CMTime?
var videoDuration: TimeInterval?
@@ -15,14 +17,25 @@ struct PlayerQueueItem: Hashable, Identifiable, Defaults.Serializable {
.init(
video,
videoID: watch.videoID,
app: watch.app,
instanceURL: watch.instanceURL,
playbackTime: CMTime.secondsInDefaultTimescale(watch.stoppedAt),
videoDuration: watch.videoDuration
)
}
init(_ video: Video? = nil, videoID: Video.ID? = nil, playbackTime: CMTime? = nil, videoDuration: TimeInterval? = nil) {
init(
_ video: Video? = nil,
videoID: Video.ID? = nil,
app: VideosApp? = nil,
instanceURL: URL? = nil,
playbackTime: CMTime? = nil,
videoDuration: TimeInterval? = nil
) {
self.video = video
self.videoID = videoID ?? video!.videoID
self.app = app
self.instanceURL = instanceURL
self.playbackTime = playbackTime
self.videoDuration = videoDuration
}