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

@@ -39,15 +39,6 @@ extension PlayerModel {
}
.onCompletion { _ in
self.logger.info("LOADED history details: \(watch.videoID)")
if self.historyItemBeingLoaded == watch.videoID {
self.logger.info("setting no history loaded")
self.historyItemBeingLoaded = nil
}
if let watch = self.historyItemsToLoad.popLast() {
self.loadHistoryVideoDetails(watch)
}
}
}
@@ -70,10 +61,11 @@ extension PlayerModel {
let watch: Watch!
let duration = self.playerTime.duration.seconds
if results?.isEmpty ?? true {
if seconds < 1 {
return
}
if seconds < 3, duration > 3 { return }
watch = Watch(context: self.backgroundContext)
watch.videoID = id
watch.appName = currentVideo.app.rawValue
@@ -82,7 +74,6 @@ extension PlayerModel {
watch = results?.first
}
let duration = self.playerTime.duration.seconds
if duration.isFinite, duration > 0 {
watch.videoDuration = duration
}
@@ -98,6 +89,8 @@ extension PlayerModel {
watch.watchedAt = Date()
try? self.backgroundContext.save()
FeedModel.shared.calculateUnwatchedFeed()
}
}