Fix:iOS local podcast episode progress #719

This commit is contained in:
advplyr 2023-06-24 10:37:56 -05:00
parent f42c624cba
commit 1ddb6eca00
3 changed files with 17 additions and 12 deletions

View file

@ -193,10 +193,14 @@ public class AbsDatabase: CAPPlugin {
@objc func updateLocalMediaProgressFinished(_ call: CAPPluginCall) {
let localLibraryItemId = call.getString("localLibraryItemId")
let localEpisodeId = call.getString("localEpisodeId")
let localMediaProgressId = call.getString("localMediaProgressId")
let isFinished = call.getBool("isFinished", false)
logger.log("updateLocalMediaProgressFinished \(localMediaProgressId ?? "Unknown") | Is Finished: \(isFinished)")
var localMediaProgressId = localLibraryItemId ?? ""
if localEpisodeId != nil {
localMediaProgressId += "-\(localEpisodeId ?? "")"
}
logger.log("updateLocalMediaProgressFinished \(localMediaProgressId) | Is Finished: \(isFinished)")
do {
let localMediaProgress = try LocalMediaProgress.fetchOrCreateLocalMediaProgress(localMediaProgressId: localMediaProgressId, localLibraryItemId: localLibraryItemId, localEpisodeId: localEpisodeId)

View file

@ -111,6 +111,7 @@ extension LocalMediaProgress {
if let episode = episode {
self.id += "-\(episode.id)"
self.episodeId = episode.id
self.localEpisodeId = episode.id
self.duration = episode.duration ?? 0.0
}
}
@ -134,6 +135,10 @@ extension LocalMediaProgress {
self.progress = finished ? 1.0 : 0.0
}
if finished {
self.currentTime = 0.0
}
if self.startedAt == 0 && finished {
self.startedAt = Date().timeIntervalSince1970 * 1000
}
@ -149,7 +154,7 @@ extension LocalMediaProgress {
self.currentTime = playbackSession.currentTime
self.progress = playbackSession.progress
self.lastUpdate = Date().timeIntervalSince1970 * 1000
self.isFinished = playbackSession.progress >= 100.0
self.isFinished = playbackSession.progress >= 0.99
self.finishedAt = self.isFinished ? self.lastUpdate : nil
}
}

View file

@ -12,16 +12,12 @@
</div>
</div>
<p class="text-lg font-semibold">
{{ title }}
</p>
<p class="text-lg font-semibold">{{ title }}</p>
<div v-if="episodeNumber || season || episodeType" class="flex py-2 items-center -mx-0.5">
<div v-if="episodeNumber" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200">Episode #{{ episodeNumber }}</div>
<div v-if="season" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200">Season #{{ season }}</div>
<div v-if="episodeType" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200 capitalize">
{{ episodeType }}
</div>
<div v-if="episodeType" class="px-2 pt-px pb-0.5 mx-0.5 bg-primary bg-opacity-60 rounded-full text-xs font-light text-gray-200 capitalize">{{ episodeType }}</div>
</div>
<!-- user progress card -->
@ -227,13 +223,13 @@ export default {
return this.$store.getters['user/getUserMediaProgress'](this.serverLibraryItemId, this.serverEpisodeId)
},
progressPercent() {
return this.userItemProgress ? this.userItemProgress.progress : 0
return this.userItemProgress?.progress || 0
},
userIsFinished() {
return this.userItemProgress ? !!this.userItemProgress.isFinished : false
return !!this.userItemProgress?.isFinished
},
userProgressFinishedAt() {
return this.userItemProgress ? this.userItemProgress.finishedAt : 0
return this.userItemProgress?.finishedAt || 0
},
userTimeRemaining() {
if (!this.userItemProgress) return 0